On Jan 27, 2014, at 7:45 AM, Bos, Roger wrote:

> All,
> 
> I would like to figure out how to pass variable names to the dplyr function 
> mutate.  For example, this works because hp is one of the variable names on 
> mtcars:
> 
> mutate(mtcars, scale(hp))
> 
> Let's says I want to pass in the target variable instead of hard-coding the 
> name, as follows:
> 
> target <- "hp"
> mutate(mtcars, scale(target))
> 
> That dones't work.  I read somewhere about using lapply, but that suggestion 
> didn't work for me either:
> 
> target <- lapply("hp", as.symbol)
> mutate(mtcars, scale(target))
> 
> Does anyone know how to do this?

You cross-posted this to the manipulatr newsgroup (where it was addressed). 
Crossposting is a practice which is not appreciated in R lists.

--

David Winsemius
Alameda, CA, USA

______________________________________________
R-help@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.

Reply via email to