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?
Thanks,
Roger
***************************************************************
This message is for the named person's use only. It may
contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the the sender by e-mail, delete the message and all
copies from your system and destroy any hard copies. You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message if you are not
the intended recipient.