[R] Specification of model formulae
Uwe Ligges
ligges at statistik.uni-dortmund.de
Fri Apr 16 17:18:43 CEST 2004
Christian Hennig wrote:
> Hi,
>
> is it true that the only way to tell rpart which variables to use
> is to specify every single variable in the formula and separate them with
> "+"?
>
> I wonder if this error...
>
>
>>rotree <- rpart(powerdata[,1]~powerdata[,2:3],
> + method="class")
> Error in model.frame(formula, rownames, variables, varnames, extras,
> extranames, :
> invalid variable type
>
> ...can be prevented by other means than...
>
>
>>rotree <- rpart(segments~V1.3+V1.9,
>
> + method="class",data=powerdata)
>
> This works.
> (The variables here are powerdata[,1] and [,2:3].)
>
> But I do not want to write 200 variable names down, as this is the real
> size of "powerdata".
>
> Is there any way around that?
>
> Christian
Consider to use
rotree <- rpart(segments ~ ., method = "class", data = powerdata)
The "." defines all variables in powerdata, except for "segments", as
usual for formulas.
Uwe Ligges
>
>
> ***********************************************************************
> Christian Hennig
> Fachbereich Mathematik-SPST/ZMS, Universitaet Hamburg
> hennig at math.uni-hamburg.de, http://www.math.uni-hamburg.de/home/hennig/
> #######################################################################
> ich empfehle www.boag-online.de
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list