I am trying to rename the column "P3Q03.1." to "P2Q03.1." in one of my dataframes. However, the name remains unchanged. Here is what I do:
colnames(df[colnames(df)=="P3Q03.1."])<-"P2Q03.1."
Here is what results:
> df$P3Q03.1. [1] Mein Mein Levels: leer Mein > df$P2Q03.1. NULL > colnames(df[colnames(df)=="P3Q03.1."])<-"P2Q03.1." > df$P3Q03.1. [1] Mein Mein Levels: leer Mein > df$P2Q03.1. NULL Both before and after the renaming attempt, trying to display column "P3Q01.1." works and displaying "P2Q01.1." does not. It is as if my renaming attempt does not do anything, but it also does not create an error message.
dplyr.df %>% rename(P2Q03.1 = P3Q03.1)names(df)[names(df) == 'P3Q03.1.'] <- 'P2Q03.1.'