我试图在R中重新编码一个因子变量并使用以下代码:
library(car)
napier_captureComplexity=recode(napier$a_SpatialConnectivity,"'1 - Very simple and clear: no diagrams, single sheets'=1;'2 - Reasonably simple: some simple diagrams or second sheets'=2;'3 - Reasonably complex: multiple diagrams or sheets but can be followed'=3;'4 - Moderately complex: multiple diagrams and sheets'=4;'5 - Very complex'=5;",as.factor.result=FALSE)
Run Code Online (Sandbox Code Playgroud)
并收到以下错误消息:
Error in parse(text = range[[1]][1]) : <text>:1:1: unexpected INCOMPLETE_STRING 1: '4 - Moderately complex
Run Code Online (Sandbox Code Playgroud)
低于数字4的^
我不确定是什么导致这种情况,我想知道:通过代码,但我没有使用c(),并且代码在数据集中具有类似字符串值的其他因素上执行得很好.
任何帮助表示赞赏!