What R package is commonly used to create HTML reports?
The rmarkdown package is commonly used to create HTML reports in R. It allows you to write documents mixing text and code that can be converted to HTML.
Click to reveal answer
beginner
How do you generate a PDF report from an R Markdown file?
You can generate a PDF report by setting output: pdf_document in the YAML header of your R Markdown file and then knitting it. This requires a LaTeX installation.
Click to reveal answer
intermediate
Which R package helps to create Word documents programmatically?
The officer package helps create and edit Word documents (.docx) programmatically in R.
Click to reveal answer
beginner
What is the role of the YAML header in R Markdown files?
The YAML header at the top of an R Markdown file specifies document options like the output format (HTML, PDF, Word), title, author, and more.
Click to reveal answer
intermediate
Why might you choose HTML output over PDF or Word in R reports?
HTML output is interactive, supports web features like links and animations, and is easy to share online. PDF and Word are better for printing or formal documents.
Click to reveal answer
Which package is primarily used to create HTML reports in R?
Armarkdown
Bggplot2
Cdplyr
Dshiny
✗ Incorrect
The rmarkdown package is designed to create HTML, PDF, and Word reports by knitting R Markdown files.
What must you have installed to create PDF reports from R Markdown?
ALaTeX distribution
BJava Runtime Environment
CPython interpreter
DNode.js
✗ Incorrect
Creating PDF reports requires a LaTeX distribution like TinyTeX to convert the markdown to PDF.
Which package allows you to create Word documents programmatically in R?
Aknitr
Bofficer
Cshiny
Dstringr
✗ Incorrect
The officer package is used to create and manipulate Word documents from R.
In R Markdown, where do you specify the output format like HTML or PDF?
AR script body
BGlobal options
CConsole commands
DYAML header
✗ Incorrect
The YAML header at the top of the R Markdown file defines the output format.
Which output format supports interactive features like links and animations?
AWord
BPDF
CHTML
DPlain text
✗ Incorrect
HTML supports interactive web features, unlike PDF or Word.
Explain how to create an HTML report from an R Markdown file.
Think about the file header and the knitting process.
You got /3 concepts.
Describe the differences between HTML, PDF, and Word output formats in R reporting.
Consider how each format is used in real life.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of using rmarkdown::render() in R?
easy
A. To create interactive Shiny web apps
B. To install R packages automatically
C. To run R scripts line by line in the console
D. To convert R Markdown files into output formats like HTML, PDF, or Word
Solution
Step 1: Understand the function purpose
rmarkdown::render() is designed to take an R Markdown file and produce a finished document in a chosen format.
Step 2: Identify output formats
This function supports output formats like HTML, PDF, and Word, converting the markdown content accordingly.
Final Answer:
To convert R Markdown files into output formats like HTML, PDF, or Word -> Option D
Quick Check:
rmarkdown::render() = convert to output formats [OK]
Hint: Remember: render() means 'make output file' [OK]
Common Mistakes:
Confusing render() with package installation
Thinking render() runs code interactively
Mixing render() with Shiny app creation
2. Which of the following is the correct way to specify PDF output in rmarkdown::render()?
easy
A. rmarkdown::render('file.Rmd', output_format = 'pdf_document')
B. rmarkdown::render('file.Rmd', output_format = 'pdf')
C. rmarkdown::render('file.Rmd', output_format = 'PDF')
D. rmarkdown::render('file.Rmd', output_format = 'pdfOutput')
Solution
Step 1: Recall correct output format names
The official output format for PDF in rmarkdown is exactly 'pdf_document'.
Step 2: Check case sensitivity and spelling
Incorrect names such as 'PDF', 'pdf', or 'pdfOutput' will cause errors.
Final Answer:
rmarkdown::render('file.Rmd', output_format = 'pdf_document') -> Option A
Quick Check:
PDF output format = 'pdf_document' [OK]
Hint: Use exact format names like 'pdf_document' [OK]
but get an error about missing LaTeX installation. What should you do?
medium
A. Restart RStudio and try again
B. Change output_format to 'html_document'
C. Install a LaTeX distribution like TinyTeX or MiKTeX
D. Remove all code chunks from the Rmd file
Solution
Step 1: Understand the error cause
PDF output requires LaTeX software to convert markdown to PDF, which is missing.
Step 2: Fix by installing LaTeX
Installing a LaTeX distribution like TinyTeX or MiKTeX provides the needed tools to create PDFs.
Final Answer:
Install a LaTeX distribution like TinyTeX or MiKTeX -> Option C
Quick Check:
Missing LaTeX = install LaTeX [OK]
Hint: PDF needs LaTeX installed to work [OK]
Common Mistakes:
Ignoring the LaTeX requirement
Changing output format without fixing LaTeX
Restarting RStudio without installing LaTeX
5. You want to create an HTML report from an R Markdown file but also include a Word version automatically in a single render call. Which approach is best?
hard
A. Set output_format = c('html_document', 'word_document') in one render call
B. Call rmarkdown::render() twice with output_format = 'html_document' and then 'word_document'
C. Use output_format = 'pdf_document' and rename the file to .html and .docx
D. Create the HTML file manually and copy-paste content into Word