我正在尝试可视化一些李克特数据。我已经成功地使用 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","VIC","QLD",..: 1 1 1 1 2 2 2 2 3 3 ...
..$ Group : Factor w/ 9 levels "NSW","VIC","QLD",..: 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","VIC","QLD",..: 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
不知道为什么会这样 - 任何帮助将不胜感激