0
0
R Programmingprogramming~30 mins

Output formats (HTML, PDF, Word) in R Programming - Mini Project: Build & Apply

Choose your learning style9 modes available
Output formats (HTML, PDF, Word)
📖 Scenario: You work as a data analyst and need to share your analysis results with your team. Different team members prefer different formats: some want HTML reports to view in browsers, others want PDF files for printing, and some want Word documents for editing.
🎯 Goal: Learn how to create output files in HTML, PDF, and Word formats using R. You will write code to generate a simple report in each format.
📋 What You'll Learn
Create a simple data frame with sample data
Set up output file names for HTML, PDF, and Word
Use R Markdown to generate reports in each format
Print confirmation messages after each report is created
💡 Why This Matters
🌍 Real World
Creating reports in multiple formats helps share data analysis results with different audiences who prefer different file types.
💼 Career
Data analysts and scientists often need to produce reports in HTML, PDF, and Word formats for presentations, documentation, and collaboration.
Progress0 / 4 steps
1
Create sample data frame
Create a data frame called sales_data with two columns: Product containing "Pen", "Notebook", "Eraser" and Sales containing 150, 200, 100 respectively.
R Programming
Need a hint?

Use data.frame() with named vectors for columns.

2
Set output file names
Create three variables: html_file set to "report.html", pdf_file set to "report.pdf", and word_file set to "report.docx".
R Programming
Need a hint?

Assign strings to variables using <-.

3
Generate HTML report using R Markdown
Use the rmarkdown::render() function to create an HTML report from a file named "report.Rmd". Set the output file to the variable html_file. Assume report.Rmd exists and uses sales_data.
R Programming
Need a hint?

Use rmarkdown::render() with input, output_file, and output_format arguments.

4
Print confirmation message
Print the message "HTML report created: report.html" exactly using print().
R Programming
Need a hint?

Use print() with the exact message string.