S Ellison a écrit :
As a work-round, try something lik

test.function <- function (formula.str, data) {
   weights <- rep(.1, 8)
   rpart(as.formula(formula.str), data, weights)
}

which works if formula.str is a string instead of a formula object.

Ok, I think I got the point. The only problem with transforming the string to a formula is that rpart raises another error:
Error in t.default(x) : argument is not a matrix


test.function <- function (form, data) {
   weights <- rep(.1, 8)
environment(form)<-environment() #re-sets the formula environment rpart(form, data, weights)
}

This works perfectly well. It will be good enough for what I need.

Thanks a lot ;-)

Xavier

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to