R rename column with replacements code example
Example 1: R rename singl edf column
colnames(trSamp)[2] <- "newname2"
Example 2: rename column in r
my_data %>%
rename(
sepal_length = Sepal.Length,
sepal_width = Sepal.Width
)
Example 3: r rename column based on variable
df %>% rename(!!variable := name_of_col_from_df)