R 如何替换<;NA>;特定列的值?
我想将行为空的列中的值替换为我的列tech.role的“NO”R 如何替换<;NA>;特定列的值?,r,factors,R,Factors,我想将行为空的列中的值替换为我的列tech.role的“NO” mental.health$tech.role <- as.factor(mental.health$tech.role) levels(mental.health$tech.role)<-c("No","Yes") Error in `levels<-.factor`(`*tmp*`, value = c("No", "Yes")) : number of levels differs mental.he
mental.health$tech.role <- as.factor(mental.health$tech.role)
levels(mental.health$tech.role)<-c("No","Yes")
Error in `levels<-.factor`(`*tmp*`, value = c("No", "Yes")) :
number of levels differs
mental.health$tech.rolemental.health$tech.role[is.na(mental.health$tech.role)]请使用dput
功能将mental.health
数据框添加到问题中(强调最小值)。这将帮助我们找出问题所在,并为您提供有用的答案
mental.health$tech.role[is.na(mental.health$tech.role)] <- 'NO'