I have several data.tables with different columns that I would like to append/rowbind. The outcome should be a data.table with all columns (not only columns appearing all of the rbinded dataset). Here is an example
library(data.table)
df1 = data.frame(a = c(1:5), b = c(6:10))
df2 = data.frame(a = c(11:15), b = c(16:20), c = LETTERS[1:5])
rbindlist(list(df1, df2), fill = TRUE)
borrowed from @kdauria's answer in this post Combine two data frames by rows (rbind) when they have different sets of columns.
But I only know my datasets as a vector of names c("a","b") because they vary from occasion to occasion. Because of that I am doing the following
goo <- function(...) rbind(...,fill=TRUE)
do.call(goo,sapply(c("a","b"),function(x) eval(parse(text=x))))
which gets the job done, but I am thinking whether there is not a more clever way construct the do.call() call.