On 4/11/2011 9:33 AM, Simon Hayward wrote:
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

Simon,

You have correctly figured out the problem; the margins argument does not work in facet_grid. It is a known bug. See, for example,

http://groups.google.com/group/ggplot2/browse_thread/thread/8a49a200ac3172a7
http://groups.google.com/group/ggplot2/browse_thread/thread/97ba6e2f469792cc

It is still there in ggplot2 0.8.9 (the latest release).

--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University

______________________________________________
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