I am kind of frustrated. I am working with a colleague and he has been producing some incredible analysis in R.
He has sent me scripts of his work so I can see the analysis, however, I am having nothing but problems getting his scripts to run.
For example, we have a dataframe called ecoreg, which consists of 25 variables and 144 observations. I have attached the script below. His first step is to reorder some of the observations, then creates a set of factors. This script works seamless for him, however, I get the error at the bottom of the script. For some reason, I can create a new factor called 'places', but cannot recode the LBM level to LB. Not sure why? I tried using the 'recode' function of the dplyr package, however, when I tried to use the new factors in analysis it defaulted to the old codes.
Please help! I cannot figure out why the code would work for him, but not for me?
*tmp*, which(places == "LBM"), value = "LB") :
invalid factor level, NA generated