I get Error: $ operator not defined for this S4 class
when I try to run a ctree
from the party package
, but only when the formula is writen as a string that I transform using as.formula()
.
Below the example :
#This works fine :
y <- ctree(formula = quotation ~ minute + temp, data=test[[1]], controls = ctree_control(mincriterion = 0.99))
#While this doesn't :
x <- "ctree(formula = quotation ~ minute + temp, data=test[[1]], controls = ctree_control(mincriterion = 0.99))"
y <- as.formula(x)
Error: $ operator not defined for this S4 class
My ultimate purpose is to create a function that iterates through the list test
to create multiple trees.
Any idea ?