我有一个变量名为studentData
的变量有5列的数据。每列有326行,但有一行有3行缺失。每列是一个5点likert值,从集合mylevels <- c('Strongly disagree', 'Disagree', 'Neither agree nor disagree', 'Agree', 'Strongly agree')
在R中处理缺少的Likert刻度值
当我打印每列的级数时,它给我的价值为6第二列(studentData $ Increased.confidence),因为它有3个失踪R将其解释为本专栏的另一个因素。
> sapply(studentData, function(x) { length(levels(x)) }) # The number of levels in each factor
ï..Increased.engagement Increased.confidence Improved.writing.skills
5 6 5
Made.useful.contribution.to.course Should.keep.games.for.future.students
5 5
正因为如此,我得到的错误,指出级别的数目应该是相同的李克特功能工作。我应该如何处理这3个缺失值?
> studentLikert <- likert(studentData)
Error in likert(studentData) :
All items (columns) must have the same number of levels
如何NA编码? –
没有NA,只有三个缺失值,因为调查受访者选择不回答它 – vipin8169
好吧,考虑让您的问题可重复使用,它可能会清理一些事情。 –