library(cheapr)
# Flexibly create a data frame
base_new_df <- function(..., .args = NULL){
args <- switch_args(..., .args = .args)
list2DF(args)
}
# Normal usage
base_new_df(x = 1, y = 2)
# Alternatively supplying a list of args instead
base_new_df(.args = list(x = 1, y = 2))
# cheapr::new_df does something similar
new_df(x = 1, y = 2)
new_df(.args = list(x = 1, y = 2))
Run the code above in your browser using DataLab