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
A bit of fiddling suggests that the problem is less to do with rpart
(which will quite happily acept weights defined inside a function) and
more to do with the formula argument to the test function.
This is probably because defining the formula in the global environment
(as you implicitly do by pl
'weights' should be a column in your 'data': that is the standard way to
specify weights to a model-fitting function.
On Tue, 3 Jun 2008, Xavier Robin wrote:
I can't get rpart accept case weights defined inside a function.
It keeps using the copy defined in the "global" environment (if they ex
I can't get rpart accept case weights defined inside a function.
It keeps using the copy defined in the "global" environment (if they
exists) instead of the function-defined ones.
Here is what I do:
test.function <- function (formula, data) {
weights <- rep(.1, 100)
rpart(formula, data, we
4 matches
Mail list logo