I am new to R and have this pretty simple question.
I am importing an equation from a json file called run.json
. The JSON looks something like this.
"equations": {
"spec": {
"expression": "x*x*x+2*x",
"seed": 0,
"range": 100
}
}
Im loading in the file like so
library("rjson")
result <- fromJSON(file = "run.json")
png('plot-spec.png', width=4, height=4, units='in', res=300)
specExpression = result$equations$spec$expression
seed = result$equations$spec$seed
range = result$equations$spec$range
# using noquote to remove quotes from the specExpression as it came in as a string
specEquation = function(x){noquote(specExpression)}
curve(
specEquation,
from=seed,
to=range,
ylab="Y",
xlab="X")
I keep getting the following error 'expr' did not evaluate to an object of length 'n'
. Not too sure what to do with it