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
You can use the rowwise function like this :
rowwise
library(tidyverse) mtcars %>% tbl_df() %>% rownames_to_column("car") %>% rowwise() %>% mutate(top_speed = ifelse("top_speed" %in% names(.), top_speed, NA), mpg = ifelse("mpg" %in% names(.), mpg, NA)) %>% select(car, top_speed, mpg, everything())