library(plyr)
rename(d, c("beta"="two", "gamma"="three"))
#> alpha two three
#> 1 1 4 7
#> 2 2 5 8
#> 3 3 6 9
rename(table_name, new_column = old_column)
#For multiple column change:
rename(table_name, new_column = old_column, new_col2 = old_col2)
df <- rename(df, new_name = old_name) #For renaming dataframe column
tbl <- rename(tbl, new_name = old_name) #For renaming tibble column
tbl <- tbl %>% rename(new_name = old_name) #For renaming tibble column using dplyrpipe
#operator
# declaring the columns of data frame
df = data.frame(
col1 = c('A', 'B', 'C', NA,'M'),
col2 = c(12.5, 9, 16.5, 20, 14.5),
col3 = c(NA, 3, 2, NA, 0))
# printing original data frame
print("Original data frame : ")
print(df)
# print("Renaming columns names ")
# renaming all the column names of data frame
df <- setNames(df, c("changed_Col1","changed_Col2","changed_Col3"))
print("Renamed data frame : ")
print(df)