My Current R Setup: My Tidyverse Cheat Sheet – The commands I use most

I am now running a fully updated and well-configured R environment on my Debian 13 (Trixie) system.

  • R version: 4.5.3 (latest available)
  • RStudio version: 2025.09.2 (recently updated)
  • tidyverse: Successfully installed and working (version 2.0.0)
  • Library location: My personal library at /home/lvydvy/R/x86_64-pc-linux-gnu-library/4.5 (this is the recommended and safest setup)

Everything is installed cleanly with all the necessary system dependencies. I no longer need to worry about permission issues when installing packages.

I can start RStudio anytime by typing rstudio & in the terminal.


Status: Ready to go! ✅

library(tidyverse)

1. Core Data Manipulation (dplyr)

What I Want to DoMy Command
Filter rowsdf %>% filter(age > 30)
Select columnsdf %>% select(name, age, score)
Create new columnsdf %>% mutate(bmi = weight / height^2)
Rename columnsdf %>% rename(full_name = name)
Sort datadf %>% arrange(desc(score))
Get summary statisticsdf %>% summarise(mean_age = mean(age))
Group + Summarisedf %>% group_by(department) %>% summarise(avg_score = mean(score))

2. My Favorite Pipe Workflow

R

df %>% 
  filter(age > 25) %>% 
  select(name, age, score) %>% 
  mutate(score_per_year = score / age) %>% 
  arrange(desc(score_per_year)) %>% 
  head(10)

3. tidyr – Cleaning Data

TaskCommand
Pivot longerpivot_longer(cols = c(col1, col2))
Pivot widerpivot_wider(names_from = year)
Separate one columnseparate(full_name, into = c(“first”, “last”), sep = ” “)
Drop rows with NAdrop_na()

4. ggplot2 – Quick Plots I Love

R

# Scatter plot
ggplot(df, aes(x = age, y = score, color = department)) +
  geom_point(size = 3) +
  theme_minimal()

# Bar chart
ggplot(df, aes(x = department, y = score)) +
  geom_col(fill = "steelblue") +
  theme_minimal()

# Histogram
ggplot(df, aes(x = score)) +
  geom_histogram(bins = 20, fill = "darkcyan")

5. Other Useful Commands

R

glimpse(df)           # Quick overview of data
count(df, department) # Count frequencies
slice_max(df, score, n = 5)   # Top 5 rows
slice_sample(df, n = 100)     # Random sample

Tip from me: Always start with the pipe %>% — it makes my code much more readable.