1

I'm trying to run this code using the sjPlot package ...

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")

The package has been properly installed, but I'm getting the following error:

Error in sjp.likert(likert_6, legendLabels = levels_6, barColor = "red",  : 
  could not find function "sjp.likert"

Is anyone else having this issue when they run this code/package? I've never used it before and have checked the website for specific instructions.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • 2
    I don't see any documentation for a function called `sjp.likert`. There is a function called `plot_likert` in that package. Where did you find this function name? – MrFlick Feb 21 '20 at 16:23

1 Answers1

4

(Maybe should be just a comment, but seems long)

My best guess is that there's a mismatch between the documentation you're looking at and the version of the package you have installed. I can find this documentation for an sjp.likert() function online, but that's for package version 2.4.1; the current version of the package (2.8.2) has plot_likert, but no sjp.likert(). Are you following an old example?

The NEWS file for sjPlot has

sjp.likert() was renamed to plot_likert().

for version 2.6.0 (which appears to have been released in 2018).

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453