[R] likert Package
Jeff Reichman
reichmanj at sbcglobal.net
Thu Aug 24 03:38:26 CEST 2017
R- Help Forum
Working with the "likert" package and I can't figure out why my "bar" graphs
are backwards (see attached). The percentages are place correctly but the
bars are backwards.
#Sample code
# libraries
library(likert)
# create data
band <- c("Band 3","Band 3","Band 3","Band 3","Band 3","Band 3","Band
3","Band 3","Band 3","Band 3",
"Band 4","Band 4","Band 4","Band 4","Band 4","Band 4","Band
4","Band 4","Band 4","Band 4")
q1 <- factor(c(1,1,2,2,2,2,1,1,1,2,1,1,1,1,1,3,2,1,1,1),levels =
c("1","2","3"))
q2 <- factor(c(1,1,1,1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1,1),levels =
c("1","2","3"))
q3 <- factor(c(2,2,2,2,2,2,2,2,2,2,1,3,2,2,2,2,2,2,2,2),levels =
c("1","2","3"))
q4 <- factor(c(3,3,3,3,3,3,3,3,2,1,2,2,3,3,3,3,3,3,3,3),levels =
c("1","2","3"))
q5 <- factor(c(2,2,2,2,3,1,1,2,2,2,2,3,3,3,3,3,3,1,1,3),levels =
c("1","2","3"))
df <- data.frame(band,q1,q2,q3,q4,q5)
summary(df)
results <- likert(df[,2:6])
summary(results)
# bar plot, this plots correctly
plot(results, type="bar")
# group by 'Band Level', this plots the bars backwards
results <- likert(df[,2:6], grouping = df$band)
plot(results, type = "bar", centered = FALSE, group.order = c("Band 3",
"Band 4"))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Figure.png
Type: image/png
Size: 16282 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20170823/632dc8f9/attachment.png>
More information about the R-help
mailing list