I have this simple code:
library(rgp)
df1 <- data.frame(x=1:10, y=sin(1:10))
grp.model <- symbolicRegression(y ~ x, df1, functionSet=functionSet("sin"))
When I execute I get the error
STARTING genetic programming evolution run (Age/Fitness/Complexity Pareto GP search-heuristic) ...
Error in mse(x, y) : Argument 's_y' is not a real vector.
I have tried the examples from https://cran.r-project.org/web/packages/rgp/vignettes/rgp_introduction.pdf, but all the examples give me nonsense constant functions.
What am I doing wrong ?
I am using R version 3.1.2 with rgp_0.4-1.
Cheers.
I too get the same error. The documentation for the erroring-out function mse states that it require "a numeric vector or list" for its arguments.
Running the str command to look at the data frame's structure indicates that x is an integer type.
> str(df1)
'data.frame': 10 obs. of 2 variables:
$ x: int 1 2 3 4 5 6 7 8 9 10
$ y: num 0.841 0.909 0.141 -0.757 -0.959 ...
Try using as.numeric() on the x vector:
library(rgp)
df1 <- data.frame(x=as.numeric(1:10), y=sin(1:10))
grp.model <- symbolicRegression(y ~ x, df1, functionSet=functionSet("sin"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With