[R] How Can I Execute a String Expression?

Donald Macnaughton donmac at matstat.com
Tue Jun 13 03:55:40 CEST 2017


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:

execute(ggstr)

Thanks for your help,

Don Macnaughton



More information about the R-help mailing list