I have a bunch of data frames with different variables. I want to read them into R and add columns to those that are short of a few variables so that they all have a common
Another option that does not require creating a helper function (or an already complete data.frame) using tibble's add_column:
add_column
library(tibble) cols <- c(top_speed = NA_real_, nhj = NA_real_, mpg = NA_real_) add_column(mtcars, !!!cols[setdiff(names(cols), names(mtcars))])