我试图使用RStdudio v1.0.153生成一个带有likert刻度数据的R图。我得到以下错误:
Error in likert(think) :
All items (columns) must have the same number of levels链接到我的数据是:wITP6xISaJJHTad3JbA/edit?usp=sharing
下面是我使用的R代码:
> library(psych)
> library(likert)
> myColor <- c("red","orange", "light blue","light green", "lavender")
> levels = c("Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree")
> think$A = factor(think$A, levels, ordered = TRUE)
> think$B = factor(think$B, levels, ordered = TRUE)
> think$C = factor(think$C, levels, ordered = TRUE)
> think$D = factor(think$D, levels, ordered = TRUE)
> think$E = factor(think$E, levels, ordered = TRUE)
> think$F = factor(think$F, levels, ordered = TRUE)
> results <- likert(think)
> plot(results, col = myColor) #Have not used this yet because of the error above发布于 2017-10-09 15:06:14
likert命令需要一个数据帧作为输入。
您应该使用likert(as.data.frame(think))。
library(psych)
library(likert)
library(readxl)
think <- read_xlsx(path="ThinkData.xlsx")
myColor <- c("red","orange", "light blue","light green", "lavender")
levels = c("Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree")
think$A = factor(think$A, levels, ordered = TRUE)
think$B = factor(think$B, levels, ordered = TRUE)
think$C = factor(think$C, levels, ordered = TRUE)
think$D = factor(think$D, levels, ordered = TRUE)
think$E = factor(think$E, levels, ordered = TRUE)
think$F = factor(think$F, levels, ordered = TRUE)
results <- likert(as.data.frame(think))
plot(results, col = myColor)

https://stackoverflow.com/questions/46646308
复制相似问题