Hello,

When plotting a barchart with ggplot it drops the levels of the factor for
which no counts are available.

For example:

library(ggplot)
mtcars$cyl<-factor(mtcars$cyl)
ggplot(mtcars[!mtcars$cyl==4,], aes(cyl))+geom_bar()
levels(mtcars[!mtcars$cyl==4,])

This shows my problem. Because no counts are available for factorlevel '4',
the label 4 dissapears from the plot. However, I would still like it to show
up, but without a bar (zero observations).

I would like to use this for the presentation of data with a Likert-like
scale.

Thanks in advance!
Bart

--
View this message in context: 
http://r.789695.n4.nabble.com/Ggplot-barchart-drops-factor-levels-how-to-show-them-with-zero-counts-tp4475417p4475417.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to