I have a data frame called VarChange containing 1005 variables such as:
row.name SamplingEvent Year Zenaida_macroura . . . 1005 variables
1 12367 S41 2005 0
2 12369 S42 2005 X
3 12370 S43 2005 4
4 OldSppName SamplingEvent Year Zenaida_macroura
5 NewSppName SampEvent Year Zenamacr
My goal is to change the column names of the data frame to the row called "NewSppName" (a maximum 8 letters code equivalent of the present variable name). This is needed to in order to not loose track of the various variables in ArcMap (which truncates all variables names to 8 characters).
Every thing looks good (i.e. R outputs the appropriate NewSppNames) when I ask for:
Var['NewSppName',]
But when I use:
colnames(VarChange) <- VarChange['NewSppName', ]
or
colnames(VarChange) <- as.character(VarChange["NewSppName",])
I get the following output:
row.names 7 Year 8 . . . 1005 variables
1 12367 S41 2005 0
2 12369 S42 2005 X
3 12370 S43 2005 4
4 OldSppName SamplingEvent Year Zenaida_macroura
5 NewSppName SampEvent Year Zenamacr
95% of the variables do change name to the value in NewSppName but a dozen or so changes to numbers instead of the character name present in NewSppName.
Any reason why? Any solution to this?