R Lesson 4: dplyr — filter, mutate, summarise

📎 This article includes 2 downloadable practice files ↓

⏱ 1 min read

📘 R Beginner Course · Lesson 4 of 6

“`r
library(readr); library(dplyr)
sales <- read_csv("sales.csv") |> mutate(amount = qty * rate)
sales |> filter(region == “North”) |> arrange(desc(amount)) |> head(5)
sales |> group_by(region) |> summarise(orders = n(), sales = sum(amount)) |> arrange(desc(sales))
“`

dplyr Excel
filter() Filter / FILTER
mutate() New formula column
arrange() Sort
group_by() + summarise() Pivot table / SUMIFS
left_join() XLOOKUP / Merge

|> is the pipe: “then”. Read the code top to bottom as a recipe.

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.

Practice

Run the script and add a summary by product.

📎 Practice files for this article

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