[TypeError]: Cannot read property 'substr' of Null

Viewed 848

For some reason, when I run a line assigning columnn names to my dataframe (df) from another data frame (nm), I can no longer view my columns using the "$" operating; instead when I put "df$" I get the following error: Cannot read property 'substr' of Null.

Loading either dataset does not produce this problem, only when I assign column names to df using the following line:

colnames(df) = nm$Var_Code

This problem has not been happening before when running this code and is rather new. I'm not sure how to approach the problem and any assistance would be appreciated.

1 Answers

I am also new to R-studio, the way I get over it is to write the row names on the first row in textfile, and import data from textfile with specifying row names of data frame to be the first row of textfile.

Related