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
If you already have a dataframe with all the required columns, say
library(tidyverse)
df_with_required_columns =
mtcars %>%
mutate(top_speed = NA_real_) %>%
select(top_speed, mpg)
then you can simply bind_rows filtering out all the rows:
mtcars %>%
rownames_to_column("car") %>%
bind_rows( df_with_required_columns %>% filter(F) ) %>%
select(car, top_speed, mpg, everything())
Note that missing columns will take the type from df_with_required_columns.