1

I'm using the likert package in R to produce plots, with overall results and then results split by subgroup.

When I make the plots without any grouping, the items are displayed from highest to lowest.

library(likert)
data(pisaitems)

items28 <- as.data.frame(pisaitems[, substr(names(pisaitems), 1, 5) == "ST24Q"])

p <- likert(items28)
plot(p)

Likert plot with items ordered from highest-rated to lowest-rated

But when I break down the results by subgroup, the items are ordered by column position in the data. Adding or removing the ordered = TRUE argument doesn't change this.

items28 <- cbind(groups = as.factor(c("A", "B", "C")), items28)

pgroups <- likert(items28[2:12], grouping = items28$groups)

plot(pgroups, ordered = TRUE)

Likert plot broken down by subgroup, with items ordered as they appear in the data

If I want the subgroup plot to be in the same order as the ungrouped plot (i.e., ST24Q10 on top, then S524Q05, etc.) rather than the default column order, can I do that? Or do I need to just manually re-order the columns in pgroups?

Edit: Interestingly, manually re-ordering the columns doesn't seem to be working either? The following code produces the same grouped figure above. I can't tell what the item order is based on now that the columns are re-ordered.

items28_g <- cbind(groups = as.factor(c("A", "B", "C")), items28)

items28_g <- items28_g %>% select(1, 11, 6, 9, 8, 4, 12, 3, 2, 5, 10, 7)

pgroups <- likert(items28_g[2:12], grouping = items28_g$groups)

plot(pgroups)
Elizabeth Brown
  • 113
  • 1
  • 1
  • 9
  • I've been trying to figure out the problem for a while, and it just doesn't make sense. It is possible to reorder all the parts of `pgroups` and it still won't work. Looking at the code: `plot.likert` calls `likert.bar.plot`, but when manually rerunning parts of the code I cannot find the line that changes the order that I introduced. In fact, when I run `attributes(plot(pgroups))`, it shows the reordering that I introduced. Yet still it plots it in the wrong order. I think it would be best to just contact the author of the package. – slamballais May 13 '21 at 20:08
  • 2
    Thank you, glad to hear someone else has looked into this! I've contacted them and will update here if I get a helpful response. – Elizabeth Brown May 17 '21 at 19:00
  • 1
    Any updates? I see this is still an issue. – Chris Bova Jan 10 '22 at 08:40

0 Answers0