我正在尝试使用sjPlot程序包运行此代码...
library(sjPlot)
likert_6 <- data.frame(as.factor(sample(1:6, 500, replace=T, prob=c(0.2,0.1,0.1,0.3,0.2,0.1))),
as.factor(sample(1:6, 500, replace=T, prob=c(0.15,0.15,0.3,0.1,0.1,0.2))),
as.factor(sample(1:6, 500, replace=T, prob=c(0.2,0.25,0.05,0.2,0.2,0.2))),
as.factor(sample(1:6, 500, replace=T, prob=c(0.2,0.1,0.1,0.4,0.1,0.1))),
as.factor(sample(1:6, 500, replace=T, prob=c(0.1,0.4,0.1,0.3,0.05,0.15))))
levels_6 <- list(c("Very strongly disagree", "Strongly disagree", "Disagree", "Agree", "Strongly Agree", "Very strongly agree"))
items <- list(c("Q1", "Q2", "Q3", "Q4", "Q5"))
sjp.likert(likert_6, legendLabels=levels_6, barColor="red", axisLabels.x=items, orderBy="pos")
该软件包已正确安装,但出现以下错误:
Error in sjp.likert(likert_6, legendLabels = levels_6, barColor = "red", :
could not find function "sjp.likert"
其他人在运行此代码/程序包时是否遇到此问题?我以前从未使用过它,并且已经查看了网站上的特定说明。
(也许应该只是评论,但似乎很长)
我的最佳猜测是,您正在查看的文档与所安装软件包的版本之间不匹配。我可以在线找到this documentation函数的sjp.likert()
,但这是针对2.4.1版的软件包的;当前版本的软件包(2.8.2)具有plot_likert
,但没有sjp.likert()
。您是否遵循旧的示例?
sjp.likert()重命名为plot_likert()。
对于版本2.6.0(似乎已于2018年发布)。