Skip to content

Instantly share code, notes, and snippets.

@jrosell
Last active March 5, 2026 08:39
Show Gist options
  • Select an option

  • Save jrosell/19f61fe39442f321038c1440f1fac192 to your computer and use it in GitHub Desktop.

Select an option

Save jrosell/19f61fe39442f321038c1440f1fac192 to your computer and use it in GitHub Desktop.
# Reference: By Josh Goldstein from Dirk Eddelbuettel on https://mastodon.social/@eddelbuettel/116132645744985793
library(data.table)
cw <- data.table(ChickWeight)
# fmt: skip
cw21 <- (
cw[Time %in% c(0, 21)]
[, Weight := weight]
[, Group := factor(paste0("Diet_", Diet))]
[, .(Chick, Group, Time, Weight)]
[order(Chick, Time)]
[1:5]
)
# Air formatter default
cw21 <- (cw[Time %in% c(0, 21)][, Weight := weight][,
Group := factor(paste0("Diet_", Diet))
][, .(Chick, Group, Time, Weight)][order(Chick, Time)][1:5])
# Air formatter with air.toml with [format] skip = ["[", "]", "`[`", "`]`"]
cw21 <- (cw[Time %in% c(0, 21)][, Weight := weight][,
Group := factor(paste0("Diet_", Diet))
][, .(Chick, Group, Time, Weight)][order(Chick, Time)][1:5])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment