For your first question, this should do what you want:
df_list <- set_names(x = df_list,
nm = ~ paste0("df_", seq_along(along.with = .x)))
For the 2nd question, you can do something like this:
col_names <- c("m", "n", "o")
df_list <- map(.x = df_list,
.f = ~ set_names(x = .x,
nm = col_names))
Hope this helps.
Edit: Replying to post #3 by @nithinmkp
The following example changes names for 2nd and 4th columns.
col_indices <- c(2, 4)
col_names <- c("B", "D")
map(.x = df_list,
.f = function(df)
{
existing_names <- names(x = df)
existing_names[col_indices] <- col_names
set_names(x = df,
nm = existing_names)
})
Is this what you want? If it solves the question, please consider marking the thread as closed. If needed, please refer to FAQ: How do I mark a solution?.