One possibility: update to ggplot2. The original ggplot isn't even on
CRAN any longer.

When I tried your example with ggplot2, the empty bar for 4 was
plotted as you'd expect.

Thanks for the small reproducible example.

Sarah

On Thu, Mar 15, 2012 at 11:47 AM, Bart6114 <bartsmeet...@gmail.com> wrote:
> 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
>

-- 
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
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