[R] use ggplot in a function to which a column name is given

hadley wickham h.wickham at gmail.com
Thu Dec 13 16:43:05 CET 2007


> great! I knew you would have thought this through. That's perfect. As
> always there's the trade-off between writing code and documenting the
> code already written. In this case the trade-off turned toward the
> code part I guess.
>
> Autodetection of strings by aes would be even greater but that would
> prevent me to assign the actual strings "u", "x", "y" to an aes
> element, which I don't see as a problem for non text related functions
> though...

It can come in handy when combining multiple datasets:

mtcarsq <- as.data.frame(mtcars ^ 2)

ggplot(mtcars, aes(x=mpg, y=wt)) + geom_point(aes(colour = "Raw")) +
geom_point(aes(colour="Squared"), data=mtcarsq)

and aes is complicated enough as it is.

Hadley

-- 
http://had.co.nz/



More information about the R-help mailing list