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?
P.S. I originally posted this on R-help. I normally would not cross-post, but someone suggested that this was a better place for this question.
Thanks,
Roger
--
You received this message because you are subscribed to the Google Groups "manipulatr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to manipulatr+...@googlegroups.com.
To post to this group, send email to manip...@googlegroups.com.
Visit this group at http://groups.google.com/group/manipulatr.
For more options, visit https://groups.google.com/d/optout.