✨ R One-Liners

Share a favourite, clever, or gloriously cursed R one-liner. Bonus points if nobody else can read it. Add yours as a new entry at the bottom.

Warning⚠️ Conflict zone

Shared file = likely merge conflict. git pull before you edit, append your snippet at the end, and practise resolving any clash. πŸ§—

The Collection

Maria β€” count rows per group without dplyr:

table(df$species)

Johan β€” the entire tidyverse in one breath:

df |> group_by(g) |> summarise(m = mean(x), .groups = "drop")

MartΓ­n β€” Tells you when it’s time to leave the lab

Sys.time()

Ale β€” lapply instead of for loops

list –> lapply(list, function(x) x^2)

Mohito β€” Prints my name

print(rev(rev(rev(rev(rev(c("Jag" ,"heter", "Mohit")))))))