-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Facet order reverts to alphabetical in grouped bar plot #119
Comments
I would love to see a solution to this :) |
I use a cheap trick, which won't work for everyone but will for some (e.g. me). If you don't want the package to alphabetize your items you can "pre-alphabetize" them yourself in the original order. Consider: `library(likert) Insert this loop [only with grouped, the simple one is pre-ordered high to low, not alphabetically]nms <- names(items24) Resume the vignettel24 <- likert(items24) # not grouped does not need thisplot(l24)l24g <- likert(items24, grouping = pisaitems$CNT) |
Sorry for messy formatting :) |
Still a problem. |
I found a solution that worked for me. create a likert object from your data. Plot it And this is the main step, relevel the factor that likert uses for the facets inside the ggplot facet_wrap call. This variable is a column called "Item" inside the myplot$data object. As follows: Where c("lev1", "lev2, "lev3") is the orders of the facets that you want. If you plot newplot you should have the desired ordering (at least worked for me). |
I would like to reopen issue #67. Much like that poster, I am finding that regardless of the order of columns in the original data frame, the facts are displayed in alphabetical order.
UPDATE: After poking around this seems to only be an issue for when the percentage arguments are set to true. If any of the following are set to true the order switches to alphabetical:
plot.percent.low
plot.percent.high
plot.percent.neutral
If they are all set to false, the facet ordering follows the columns in the original data frame. My guess is that something is a bit wonky when the function is asked to calculate percents.
The text was updated successfully, but these errors were encountered: