[R] How to translate string to variable inside a command in an easy way in R
Greg.Snow at imail.org
Tue Jul 5 20:50:46 CEST 2011
You are suffering from the fact that the longest distance between 2 points is a shortcut.
The df$column notation is a shortcut for df[[column]] that has some nice properties, but the shortcut gets in the way when you want to do something more structured. Try qq1[[z]]==y and avoid all that pasting, parsing, and evaluating.
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of UriB
> Sent: Tuesday, July 05, 2011 4:30 AM
> To: r-help at r-project.org
> Subject: [R] How to translate string to variable inside a command in an
> easy way in R
> I want to write a function that get 2 strings y and z and does the
> R command.
> for example if it get y="AMI" and z="PrimaryConditionGroup"
> It should do the following
> I could do it by the following function that is ugly and I wonder if
> is an easier way to do it espacielly when temp is not the final result
> I want (so I practically do not have temp<<-temp because I do not need
> function to remember temp but only to remember something else that is
> calculated based on temp).
> View this message in context: http://r.789695.n4.nabble.com/How-to-
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help