Re: Problem with geom_histogram and facet_grid

583 views
Skip to first unread message

Ista Zahn

unread,
Apr 19, 2013, 7:45:53 AM4/19/13
to Bruce Koch, ggplot2
Hi Bruce,

On Thu, Apr 18, 2013 at 3:27 PM, Bruce Koch <bruce...@gmail.com> wrote:
> I'm probably just doing something stupid, but I get this error message
> "invalid argument to unary operator" from this code:
>
> ggplot(CSIF_Customers,aes(optical)) + geom_histogram()
> + facet_grid (. ~ CSIF_Customers$Use_Level)

There are two problems with this: 1) the second '+' must be on the
same line as geom_histogram() and 2) facet_grid should specify just
the variable name, not the data.frame. Here is the corrected version:

ggplot(CSIF_Customers,aes(optical)) +
geom_histogram() +
facet_grid (. ~ Use_Level)

Best,
Ista

>
> The first line of code produces a single histogram containing all of the
> data.
>
> platform x86_64-w64-mingw32
> R version 2.15.3 (2013-03-01)
> ggplot 0.9.3.1
> run through R Studio 0.97.314
>
> The data is attached.
>
> Thanks,
>
> Bruce
>
> --
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ggplot2+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
Reply all
Reply to author
Forward
0 new messages