I’m using the Deriv package, which generates new functions, and I want to store that code into a file, from within an R program.
So I define a function:
f=function(x){x^2}
And I calculate the derivative:
fd=Deriv(f,”x”)
fd is now a new function.
On the console I can type “fd”, and that will show me the code for the new function.
On the console, I can then use the following 3 commands to save that function into a file, for future use:
sink(“myderiv.R”,type=”output”)
fd
sink()
Now, I want to run all those commands from within an R program.
It seems to me that I want to convert the output from Deriv into a string, but I don’t know how to do that.