Re: [R] Question about ggplot2

From: William Dunlap <wdunlap_at_tibco.com>
Date: Thu, 26 May 2011 15:17:38 -0700

> -----Original Message-----
> From: Brian Diggs [mailto:diggsb_at_ohsu.edu]
> Sent: Thursday, May 26, 2011 2:59 PM
> To: William Dunlap
> Cc: Julian TszKin Chan; r-help_at_r-project.org
> Subject: Re: Question about ggplot2
>
> On 5/26/2011 2:15 PM, William Dunlap wrote:
> > eval(substitute(
> >
> qplot(x=xVariable,y=yVariable,data=diamonds,geom=c('point','smooth')),
> > list(xVariable=as.name("carat"), yVariable=as.name("price"))
> > ))
>
> Well, yes, I suppose there is that. I've mentally (perhaps
> inappropriately) lumped substitute() with parse() as being subject to
> fortune(106) and have avoided it.

If a function uses substitute() or its equivalent to avoid evaluating its arguments in the normal way, you are pretty much forced to use eval() with the output of substitute() or call() or use do.call() to evaluate the arguments it will not evaluate for itself.  

>
> And this is also why I have learned to say "I don't know
> of..." rather
> than "There is not..." :)
>
> > 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.
> >>
> >
>
>
> --
> 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. Received on Thu 26 May 2011 - 22:19:39 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 26 May 2011 - 22:40:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive