rename column in r data frame code example
Example 1: r change column name in dataframe
df <- df %>%
rename(newName1 = oldName1 ,
newName2 = oldName2)
Example 2: rename column in r
my_data %>%
rename(
sepal_length = Sepal.Length,
sepal_width = Sepal.Width
)
Example 3: r dataframe change column name
names(df)[1] <- paste("newName")
Example 4: r rename column based on variable
rename(df, !!metric:=value)