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 ?
as.formulaonly applies to the formula part. So it should bex <- as.formula(quotation ~ minute + temp); and the line aftery <- ctree(formula=x, ...). For example if I use iris data set, it would be:x1 <- as.formula(Species ~ Petal.Length + Petal.Width);y1 <- ctree(formula = x1, data=iris)- chappersctreeconsidered if not as a formula ? I need to iterate outside of the scope of what you described as x. - Yohan Obadiacaretpackage. It hastrainfunction withtuneGridargument which sounds like what you're after. - chappers