R Lesson 6: Project β€” A Sales Analysis Report

R Lesson 6: Project β€” A Sales Analysis Report featured illustration

πŸ“Ž This article includes 2 downloadable practice files ↓

⏱ 1 min read

πŸ“˜ R Beginner Course Β· Lesson 6 of 6

In this article
  1. Reports with Quarto
  2. Practice
  3. Continue learning

The script reads the data, calculates KPIs (orders, total, average order), summarises by product, writes a CSV and saves a chart. Run it again next month on new data and everything updates.

Advertisement
kpi <- sales |> summarise(orders = n(), total = sum(amount), avg = round(mean(amount)))
product <- sales |> group_by(product) |> summarise(qty = sum(qty), sales = sum(amount)) |> arrange(desc(sales))
write_csv(product, "product_summary.csv")

Reports with Quarto

RStudio’s File β€Ί New File β€Ί Quarto Document mixes text and R code chunks and renders to HTML, Word or PDF, so the whole report rebuilds with one click.

πŸ’‘ Keep raw data, scripts and outputs in separate folders (data/, R/, output/) inside the project. Future you will thank you.

That’s the R course.

Code for this course follows standard, current syntax; we test JavaScript and PowerShell scripts before publishing, and R/Java/Rust examples are kept to core language features. Tell us if anything fails on your setup.

Advertisement

Practice

Run the project script and check the CSV and PNG it creates.

πŸ“Ž Practice files for this article

⬇ Download all 2 files (ZIP Β· 785 B)

Free to use for learning. Files with macros (.bas) are plain text β€” import them with Alt+F11 β†’ File β†’ Import File, and always test on a copy.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free Β· AI can be wrong