Message-ID: <47664684.7070108@web.de>
Date: 2007-12-17T09:51:00Z
From: Christian Schulz
Subject: paste dependent variable in formula (rpart)?
In-Reply-To: <4765B435.4030000@statistik.uni-dortmund.de>
> Christian Schulz wrote:
>
>> Hello,
>>
>> i'm trying to replace different target variables in rpart with a
>> function. The data.frame getting always the target variable as last column.
>> Try below, i get the target variable in the explained variables, too!?
>> Have anybody an advice to avoid this.
>>
>> rp1 <- rpart(eval(parse(text=paste(names(train[length(train)])))) ~ . ,
>>
>
> I guess you want something along the following example:
>
> train <- iris
> form <- as.formula(paste(names(train)[length(train)], "~ ."))
> rpart(form, data = iris)
>
> or some data.frame method for rpart....
>
yes ,many thanks!
Christian
>
> Uwe Ligges
>
>
>
>> data=train,cp=0.0001)
>>
>> regards & many thanks
>> Christian
>>
>> ______________________________________________
>> R-help at 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.
>>
>
> ______________________________________________
> R-help at 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.
>
>