我想使用 Likert 包,并按变量分组并绘制结果。问题是我想要可视化的变量有不同的级别。有没有解决的办法 ?
一个简单的例子来说明我的问题:
library(reshape)
library(likert)
foo <- data.frame(car = rep(c("Toyota", "BMW", "Ford"), times = 10),
satisfaction = c(1,3,4,7,7,6,2,3,5,5,5,2,4,1,7),
quality = c(1,1,3,5,4,3,6,4,3,6,6,1,7,2,7),
loyalty = c(1,1,3,5,4,3,9,4,3,10,6,1,7,2,8) )
foo[1:4] <- lapply(foo[1:4], as.factor)
likt <- likert(foo[,c(2:4)], grouping = foo$car)
plot(likt)
错误信息:
Error in likert(foo[, c(2:4)], grouping = foo$car) :
All items (columns) must have the same number of levels