jbryer / likert

Package to analyze likert based items.
309 stars 124 forks source link

Incorrect ploted level order when using grouping #63

Closed ruialv closed 7 years ago

ruialv commented 7 years ago

Hello,

First things first: thank you for this great package! I use it a lot. Now, let's try to replicate the bug(?).

require(likert)

Using demo data data(pisaitems) items28 <- pisaitems[, substr(names(pisaitems), 1, 5) == "ST24Q"]

Prepare data to plot likert l28 <- likert(items28)

Levels are ploted in the correct order plot(l28)

image

Prepare grouped data by CNT to plot likert l28g <- likert(items28, grouping = pisaitems$CNT)

"Strongly agree" apears before "Agree" level plot(l28g)

image

Here's my session info:

sessionInfo() R version 3.3.0 (2016-05-03) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

locale: [1] LC_COLLATE=Portuguese_Portugal.1252 LC_CTYPE=Portuguese_Portugal.1252
[3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Portugal.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] likert_1.3.4 xtable_1.8-2 ggplot2_2.2.0

loaded via a namespace (and not attached): [1] Rcpp_0.12.8 digest_0.6.10 psych_1.6.9 assertthat_0.1
[5] grid_3.3.0 plyr_1.8.4 gtable_0.2.0 magrittr_1.5
[9] scales_0.4.1 stringi_1.1.2 reshape2_1.4.2 lazyeval_0.2.0
[13] labeling_0.3 tools_3.3.0 foreign_0.8-67 stringr_1.1.0
[17] munsell_0.4.3 parallel_3.3.0 colorspace_1.3-1 mnormt_1.5-5
[21] gridExtra_2.2.1 tibble_1.2

I've been keeping all packages updated. Could it be related to ggplot2 version 2.2.0? (Just tried with 2.1.0 version and had the same issue) [UPDATE: It really is related to ggplot2_2.2.0, works fine with 2.1.0. One needs to uninstall 2.2.0, restart R and install 2.1.0] Thanks,

Rmadillo commented 7 years ago

I have the same issue. I've been playing around in likert.bar.plot around lines 87 and 189 with various combinations of trying to reverse the data and the fill, e.g.,:

                geom_bar(data = results.high[nrow(results.high):1,], aes(fill = rev(variable)), 
                    stat = "identity")

I can get the colors to correctly order by using rev with the fill part, but the data is wrong, still in the wrong order from highest at 0 to lowest at the right end of the bar.

I did get the colors and order to work using this instead of the above:

                geom_bar(data = results.high, aes(fill = variable, group=rev(variable)), 
                    stat = "identity")

However, I don't know why it works, since the lines above them don't need the group formally specified. Hopefully the package owners will be able to sort that out?

Rmadillo commented 7 years ago

FWIW, the values/color order also fails to plot correctly when you use grouping and centered = FALSE.

mansonp commented 7 years ago

I also have a extra response type showing up on grouped data plots. Along with this swapped value issue.

randallgrout commented 7 years ago

I can second that this happens when using ggplot2 2.2.0. Reverting to 2.1.0 fixes it. Perhaps it is related to the new stacking methods used in the ggplot2.

jpaulbrowning commented 7 years ago

I have the same problem, and beat my head against the wall until finding this thread. ggplot2 2.1.0 fixed it for me as well.

lisaerein commented 7 years ago

I was having the same problem this fixed it - thank you so much for posting!!!!

jbryer commented 7 years ago

This has been fixed and on CRAN now.

Rmadillo commented 7 years ago

Thanks, Jason, for the update, but many more thanks for such a great package!!!

avierse commented 6 years ago

This still isn't working for me. Is there a package I should update? I tried re-ordering my levels and it's still not reading in the Likert plot.

Thanks!

jbryer commented 6 years ago

With all the changes to ggplot2, this package needs updating. It is on my list to work on this summer.

On Wed, May 16, 2018 at 11:29 AM, avierse notifications@github.com wrote:

This still isn't working for me. Is there a package I should update? I tried re-ordering my levels and it's still not reading in the Likert plot.

Thanks!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/jbryer/likert/issues/63#issuecomment-389561563, or mute the thread https://github.com/notifications/unsubscribe-auth/AAmEjxdHn0Li45OaC803u0sqVA4sz8s1ks5tzEW_gaJpZM4K4aUg .

yrhe commented 5 years ago

Hello, thank you very much for providing this very useful package! I noticed this issue has been closed, but I still have this issue, the color is incorrect. The version of ggplot2 installed is 3.1.1.