How do I plot a function formatted as a string in R -
i building application rapache , code in r receiving post data. 1 of post datas post$f string- "sin(x)". there way put plot function successfully?
thanks!
fun <- "sin(x)" plot(function(x) eval(parse(text=fun))) but not recommend. eval(parse(...)) dangerous, , arbitrary user input web site gaping security hole.
# plotting function above delete in global workspace fun <- "{rm(list=ls(pos=1),pos=1); x}" # don't didn't warn you! or using system() more bad things.
Comments
Post a Comment