R中具有不同级别的李克特分组 [英] Likert grouping with different levels in R
本文介绍了R中具有不同级别的李克特分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用Likert软件包,并按变量分组并绘制结果.问题是我要可视化的变体的级别不同.有办法解决吗?
I would like to use the Likert package and also to group by variable and plot the result. The problem is that I have different levels in the variabels I want to visualise. Is there a way around this ?
一个简单的例子来说明我的问题:
A simple example to illustrate my problem:
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
推荐答案
与第一个答案相同,但现在作为组的函数.
Same as first answer, but now as a function of group.
foo[2:4] <- lapply(foo[2:4], factor, levels=1:10)
likt <- likert(foo[,c(2:4)], grouping = foo$car)
plot(likt)
这篇关于R中具有不同级别的李克特分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文