Most analytical work relies on a small set of core calculations.
Master these 10 operations in R and you’ll cover 80% of real‑world dashboards, reports, and automation tasks.
Below is a clean, practical guide with minimal theory and maximum usefulness.
- Sum, Mean, Median r x <- c(10, 20, 30, 40)
sum(x)
mean(x)
median(x)
- Grouped Calculations (dplyr) r library(dplyr)
df %>%
group_by(region) %>%
summarise(
avg_sales = mean(sales),
total = sum(sales)
)
- Percent Change r percent_change <- (new - old) / old * 100
- Rolling Calculations r library(zoo)
rollmean(df$value, k = 7, fill = NA)
- Cumulative Calculations r cumsum(x) cumprod(x)
- Ranking & Percentiles r rank(x) quantile(x, probs = 0.9)
- Row‑wise Calculations r rowSums(df) rowMeans(df)
- Conditional Calculations r df %>% mutate(score = case_when( value > 90 ~ "High", value > 70 ~ "Medium", TRUE ~ "Low" ))
- Correlation & Covariance r cor(df$x, df$y) cov(df$x, df$y)
- Mini KPI Block r df %>% summarise( total = sum(value), avg = mean(value), pct_change = (last(value) - first(value)) / first(value) * 100, p90 = quantile(value, 0.9) )
Tools & Resources
Payhip Store:
https://payhip.com/CrisDigital
Gumroad Store:
https://gabrieli112.gumroad.com
Top comments (0)