I have merged several data frames and the headers lack clarity. I need to change them from 'Indicator' to 'NEWNAMES'
The data frame I created is called new_names and follows this pattern :
**NEWNAME** **Indicator**
Housing price Indicator1
Water Stress WSL
the dataframe that needs changed is 'WS_MAT' and looks like this
Country Year Indicator1 EMP.c WSL
FR 2015 22 23 23
USA 2019 1000 513 55
I tried
colnames(WS_MAT) <- ifelse(colnames(WS_MAT)==new_names$Indicator,new_names$NEWNAME, colnames(WS_MAT))
but I get an error message : Error in dimnames(x) <- dn : la longueur de 'dimnames' [2] n'est pas égale à l'étendue du tableau
Sorry my computer is in French, but from what I understood, it treats colnames as a function. If you have any suggestion, please let me know! thanks.