An lapply should work fine, you just need to specify the factor() function:csc2[1:3] <- lapply(csc2[1:3], function(x) factor(x, eLevels))然后您可以像这样调用表:Then you can call table like:table(csc2[1])#Strongly Disagree Disagree Neither A or D Agree Strongly Agree# 0 0 0 2 1table(csc2[2])#Strongly Disagree Disagree Neither A or D Agree Strongly Agree# 0 0 0 3 0 这篇关于将因子级别应用于缺少因子级别的多个列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-19 18:56
查看更多