[R] Problem with facet_grid in ggplot2

Simon Hayward SHayward at agenda21digital.com
Mon Apr 11 18:33:42 CEST 2011

Hi all,

I am practising a bit with ggplot2 but I have a problem when I try to
use facet_grid.

The following code:- 

p <- ggplot(diamonds, aes(carat, ..density..)) +
+ geom_histogram(binwidth = 1)

p + facet_grid(cut ~ clarity, margins=TRUE)

produce the following error:-

Error in class(output[[var]]) <- class(value) : 
  cannot set class to "array" unless the dimension attribute has length
> 0

I have lifted this code directly from the ggplot2 documentation!

By a process of elimination it seems that the problem arises from the
use of margins.

I do not know why the dimension attribute is conflicting with margins
unless it is something to do with the properties of the data frame.

I am running R 2.12.1

Has the source code changed?

Very grateful for any help

Simon Hayward

More information about the R-help mailing list