I am trying to create Grouped Likert Plot using plot_liker command under sjPlot in R. Tried to execute the following command:
library(sjPlot)
library(ggplot2)
library(readxl)
mydf1<- read_excel("C:\\Users\\HP\\Desktop\\aa\\source_teacher.xlsx")
mydf1<- data.frame(mydf1)
mydf1$Domain <- factor(mydf1$Domain)
legend_labels <- c("1 Never", "2 Sometime", "3 Often", "4 Very Often") # Plotting with custom legend
p <- plot_likert(mydf1[1:4], groups = mydf1$Domain,
catcount = 4,
legend.labels = legend_labels)
p + theme(
axis.text.y = element_text(color = "black", size = 14),
legend.position = "bottom"
)
It gives an error:
Error: Length of groups has to equal the number of items: ncol(items) != length(groups).
The data set is
Online Journals | Online Databases | E-books | Others | Domain |
---|---|---|---|---|
4 | 2 | 1 | 4 | Teacher |
3 | 3 | 4 | 2 | Teacher |
2 | 1 | 4 | 3 | Student |
1 | 3 | 2 | 4 | Student |
Require a grouped likert plot by grouping 'Teacher' and 'Student'.