rename columns in rstudio code example
Example 1: r: rename a column
colnames(df)[which(names(df) == "columnName")] <- "newColumnName"
Example 2: r rename column based on variable
df %>% rename(!!variable := name_of_col_from_df)
colnames(df)[which(names(df) == "columnName")] <- "newColumnName"
df %>% rename(!!variable := name_of_col_from_df)