i want to create a data.table and I want to use dynamic column names, by the way this is not about adding columns to an existing data.table.
Here is an example
outer.name <- "outer.column"
outer.members <- c("I", "II")
outer.members.cnt <- length(outer.members)
dt.outerinner <- data.table(outer = outer.members)
setnames(dt.outerinner, outer.name)
Now I want to know, if it's possible to pass the variable "outer.name" directly to data.table(... = outer.members) and omit setnames(...)?
Any hint is appreciated
Tom
setnames(dt.outerinner <- data.table(outer.name = outer.members), outer.name)library(magrittr); data.table(outer.members) %>% setnames(outer.name) -> dt.outerinner