[R] ggplot2: proper use of facet_grid inside a function

baptiste auguie baptiste.auguie at googlemail.com
Mon Oct 5 16:16:51 CEST 2009


Now why do I always come up with a twisted bquote() where a simple
paste() would do!

Thanks,

baptiste


2009/10/5 hadley wickham <h.wickham at gmail.com>:
>> Whether or not what follows is to be recommended I don't know, but it
>> seems to work,
>>
>> p <- ggplot(diamonds, aes(carat, ..density..)) +
>>  geom_histogram(binwidth = 0.2)
>>
>> x = quote(cut)
>> facets = facet_grid(as.formula(bquote(.~.(x))))
>> p + facets
>
> That's what I'd recommend.  You can also just do
>
> facets <- facet_grid(paste(". ~ ", var))
>
> Hadley
> --
> http://had.co.nz/
>




More information about the R-help mailing list