β¨ 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")))))))