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