I have a list of dataframes
vars <- c("Col_1", "Col_2", "Col_3")
list_df <- list(
tibble(
a = 1,
b = 2,
c = 3
),
tibble (
d = 1,
e = 2,
f = 3
)
)
And I'd like to rename the columns using the vars but I think I'm missing something here.
map(list_df, ~rename_all(.x, vars))
The result should be:
list(
tibble(
Col_1 = 1,
Col_2 = 2,
Col_3 = 3
),
tibble (
Col_1 = 1,
Col_2 = 2,
Col_3 = 3
)
)
I'd like this to work regardless of the initial column names (and all data frames will always only have three columns. Is this possible?