Some syntactic sugar for R.
Appending objects to lists
Assume we have an list and some objects we want to be named parts of this list.
mylist <- list() numbers <- 1:20 breakfast <- "chunky bacon" wood <- list(oak = "hard", spruce = "soft")
In R, you usually do
mylist$numbers <- numbers
to append a single object to this list. The same thing has to be done for multiple objects:
mylist$breakfast <- breakfast mylist$wood <- wood
The sugar provided shortens this to:
mylist %$% numbers
for the case of appending a single object, and for multiple objects to:
mylist %$% c(breakfast, wood)
This is achieved using global assignment, so be careful when using this non-interactively.
Loading multiple packages with one call
library(utils) library(mgcv) library(sp)
We can do
libraries(utils, mgcv, sp)