[R] Question about ggplot2

William Dunlap wdunlap at tibco.com
Thu May 26 23:15:12 CEST 2011


eval(substitute(
  qplot(x=xVariable,y=yVariable,data=diamonds,geom=c('point','smooth')),
  list(xVariable=as.name("carat"), yVariable=as.name("price"))
))

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Brian Diggs
> Sent: Thursday, May 26, 2011 2:07 PM
> To: Julian TszKin Chan
> Cc: r-help at r-project.org
> Subject: Re: [R] Question about ggplot2
> 
> On 5/26/2011 12:29 PM, Julian TszKin Chan wrote:
> > Hi all,
> >
> > Is there any way for me to to string in the argument of 
> qplot or ggplot? for
> > example
> >
> > qplot(x='carat',y='price',data=diamonds,geom=c('point','smooth'))
> > instead of
> > qplot(x=carat,y=price,data=diamonds,geom=c('point','smooth'))
> 
> I don't know of a way using qplot, but it is possible with 
> ggplot.  Use 
> aes_string instead of aes:
> 
> ggplot(diamonds, aes(x=carat, y=price)) + geom_point() + geom_smooth()
> 
> ggplot(diamonds, aes_string(x="carat", y="price")) + geom_point() + 
> geom_smooth()
> 
> >   Thanks!!
> >
> > Regards,
> > TszKin Julian
> >
> > 	[[alternative HTML version deleted]]
> 
> -- 
> Brian S. Diggs, PhD
> Senior Research Associate, Department of Surgery
> Oregon Health & Science University
> 
> ______________________________________________
> R-help at 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.
> 



More information about the R-help mailing list