R for Excel Users: Your First Data Summary in 15 Lines

R for Excel Users: Your First Data Summary in 15 Lines

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

⏱ 2 min readUpdated 27 September 2026

R is built for statistics and charts. If your Excel work involves averages, distributions or trends, R can do in a few lines what takes many clicks. Install R from CRAN and RStudio (free), then follow along.

In this article
  1. Install the packages (once)
  2. The 15 lines
  3. Reading it like Excel
  4. Try it yourself: step by step

Install the packages (once)

install.packages(c("readxl", "dplyr", "ggplot2"))

The 15 lines

library(readxl)
library(dplyr)
library(ggplot2)

sales <- read_excel("sales.xlsx", sheet = "Data")

summary_tbl <- sales |>
  mutate(amount = qty * price) |>
  group_by(region) |>
  summarise(orders  = n(),
            revenue = sum(amount),
            avg_order = mean(amount)) |>
  arrange(desc(revenue))

print(summary_tbl)

ggplot(summary_tbl, aes(x = reorder(region, revenue), y = revenue)) +
  geom_col(fill = "#e47f53") + coord_flip() +
  labs(x = NULL, y = "Revenue", title = "Revenue by region")

Reading it like Excel

R Excel equivalent
mutate(amount = qty * price) Add a formula column
group_by(region) + summarise() Pivot table with region in Rows
arrange(desc(revenue)) Sort largest to smallest
ggplot(...) + geom_col() Insert β†’ Bar chart

The |> symbol (the β€œpipe”) passes the result of one step into the next. Read it as β€œand then”.

πŸ’‘ Where R really shines is the next step: summary(sales$amount) gives min, quartiles, median and mean in one line, and geom_histogram() shows the distribution β€” handy for spotting outliers before month-end.

Try it yourself: step by step

  1. Install R and RStudio (both free). Download sales.xlsx and first_summary.R into one folder.
  2. Open first_summary.R in RStudio, then Session β†’ Set Working Directory β†’ To Source File Location.
  3. Run install.packages(c("readxl","dplyr","ggplot2")) once in the Console.
  4. Click Source. The summary table prints in the Console and the bar chart appears in the Plots pane.
  5. Try summary(sales$Qty) in the Console for min, quartiles, median and mean in one line.

πŸ“Ž 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.