我正在尝试绘制一个简单的Likert图。不知何故,我无法设置legends
的值。任何人都可以告诉我我该怎么做?以下是我正在使用的脚本和我得到的图表:
Q2 <- c(11.76, 11.76, 17.65, 47.06, 11.76)
Q3 <- c(0, 17.65, 23.53, 23.53, 35.29)
Q4 <- c(5.88, 35.29, 23.53, 29.41, 5.88)
Q <- data.frame(Q2, Q3, Q4)
Q <- t(Q)
levels_4 <- list(c("Strongly disagree", "Disagree", "Agree", "Strongly Agree"))
items <- list(c("Q1", "Q2", "Q3", "Q4", "Q5"))
likert(Q, legendLabels=levels_4)
答案 0 :(得分:3)
将语法更改为:
Q2 <- c(11.76, 11.76, 17.65, 47.06, 11.76)
Q3 <- c(0, 17.65, 23.53, 23.53, 35.29)
Q4 <- c(5.88, 35.29, 23.53, 29.41, 5.88)
Q <- data.frame(Q2, Q3, Q4)
Q <- t(Q)
colnames(Q) <- c("Strongly disagree", "Disagree", "Neutral", "Agree", "Strongly Agree")
items <- list(c("Q1", "Q2", "Q3", "Q4", "Q5"))
likert(Q)
运行时修复它。我不太熟悉HH包和likert()函数,因此我无法立即解释原因,但指定colnames确实有效。