[R] How Can I Execute a String Expression?
r.turner at auckland.ac.nz
Tue Jun 13 04:26:46 CEST 2017
On 13/06/17 13:55, Donald Macnaughton wrote:
> I have the string ggstr that I've built with string manipulation:
> ggstr = "ggplot(df1, aes(x,y)) + geom_smooth(se=FALSE, span=0.01)"
> Assuming df1 is properly defined, this string will execute properly if I
> submit it manually without the quotes. How can execute the command as a
> string, so that I can run it repeatedly (with minor modifications) in a
> loop? Presumably, it would be something like:
> Thanks for your help.
eval(parse(text = ggstr))
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
More information about the R-help