sjPlot库是否有问题?

问题描述 投票:0回答:1

我正在尝试使用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"

其他人在运行此代码/库时是否遇到此问题?我以前从未使用过它,并且已经查看了网站上的特定说明。我对R自己还很陌生。

r bar-chart sjplot
1个回答
0
投票

(也许应该只是评论,但似乎很长)

我的最佳猜测是,您正在查看的文档与所安装软件包的版本之间不匹配。我可以在线找到this documentation函数的sjp.likert(),但这是针对2.4.1版的软件包的;当前版本的软件包(2.8.2)具有plot_likert,但没有sjp.likert()。您是否遵循旧的示例?

NEWS file for sjPlot具有

sjp.likert()重命名为plot_likert()。

对于版本2.6.0(似乎已于2018年发布)。

© www.soinside.com 2019 - 2024. All rights reserved.