如何解决使用likert() 时分组汇总结果出错
我正在尝试可视化一些李克特数据。我已经在所有使用 likert() 的受访者中成功地做到了这一点
df <- data[,11:14]
df[] <- lapply(df,factor,levels=c(1,2,3,4,5),labels = c("Strongly disagree","disagree","Neutral","Agree","Strongly agree"))
df <- data.frame(df)
LK <- likert(df)
LK <- likert(summary = LK$results)
plot(LK,include.center=FALSE)+ggtitle("Title")
为了按组切割,我使用了以下代码(有效):
LK2 <- likert(df,grouping = data$group)
str(LK2$results)
'data.frame': 34 obs. of 7 variables:
$ Group : Factor w/ 9 levels "NSW","VIC","QLD": 1 1 1 1 1 1 1 1 1 1 ...
$ Item : Factor w/ 4 levels "Question_1",..: 1 2 3 4 5 6 7 8 9 10 ...
$ Strongly disagree: num 18.18 13.64 12.12 15.15 9.09 ...
$ disagree : num 19.7 16.7 10.6 24.2 22.7 ...
$ Neutral : num 27.3 34.8 45.5 22.7 27.3 ...
$ Agree : num 24.2 22.7 18.2 24.2 24.2 ...
$ Strongly agree : num 10.6 12.1 13.6 13.6 16.7 ...
但是当我从这些结果中总结出来进行绘图时:
LK3 <- likert(summary = LK2$results,grouping = LK2$results[,1])
str(LK3)
List of 5
$ results :'data.frame': 28 obs. of 8 variables:
..$ Group : Factor w/ 9 levels "NSW","QLD",..: 1 1 1 1 2 2 2 2 3 3 ...
..$ Group : Factor w/ 9 levels "NSW",..: 1 1 1 1 2 2 2 2 3 3 ...
..$ Item : Factor w/ 4 levels "Question_1",..: 1 2 3 4 1 2 3 4 1 2 ...
..$ Strongly disagree: num [1:28] 16.22 16.22 8.11 18.92 14.29 ...
..$ disagree : num [1:28] 18.9 18.9 13.5 16.2 19 ...
..$ Neutral : num [1:28] 35.1 27 48.6 21.6 42.9 ...
..$ Agree : num [1:28] 16.2 24.3 13.5 29.7 19 ...
..$ Strongly agree : num [1:28] 13.51 13.51 16.22 13.51 4.76 ...
$ items : NULL
$ grouping: Factor w/ 9 levels "NSW",..: 1 1 1 1 2 2 2 2 3 3 ...
$ nlevels : num 6
$ levels : chr [1:6] "Item" "Strongly disagree" "disagree" "Neutral" ...
- attr(*,"class")= chr "likert"
它似乎重复了“组”,当我尝试绘制时,我收到以下错误消息:
plot(LK3)
Error in FUN(newX[,i],...) : invalid 'type' (character) of argument
不知道为什么会这样 - 任何帮助将不胜感激
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。