Dear users, I'm using rpart for classification trees, but my code isn't working when I try to use all the variables in my data frame. This data frame was created from a data frame with 1775 variables, but I choose only 13. arv13<-rpart(iv~.,data=gn,method="class",parms=list(split="information")) #Error: Error in `[.data.frame`(frame, predictors) : undefined columns selected "gn" is a data.frame, so I don't understand where is my mistake. If I read the data.frame from a txt file "g13.txt" previously saved, instead creating the data.frame "gn" from the data frame with 1775 variables (columns), it works. My question is: which properties must the data file have to use rpart doing "iv ~ ." ? Thank you very much, My best regards Lu?sa S?co -------------- next part -------------- "iv" "754" "923" "972" "1058" "1223" "2118" "2593" "2605" "2777" "3055" "3186" "3193" "3393" "1" 3 1 0 1 1 1 1 0 0 0 1 0 0 0 "2" 2 1 1 1 1 0 0 1 0 0 0 1 1 1 "3" 2 1 0 1 1 0 0 1 1 0 0 1 0 1 "4" 3 1 1 1 1 0 0 0 0 0 1 1 0 0 "5" 2 1 1 1 1 0 0 1 0 0 1 1 0 0 "6" 2 1 1 1 1 0 0 1 0 0 0 0 1 1 "7" 1 1 0 1 1 0 1 0 1 0 0 0 1 1 "8" 3 1 1 1 1 0 1 0 0 0 0 1 1 1 "9" 2 1 0 1 1 0 0 0 0 0 1 0 0 1 "10" 2 1 1 0 1 0 0 1 0 0 1 0 1 0 "11" 2 1 0 1 1 0 0 0 0 0 1 0 0 1 "12" 1 1 1 1 1 1 1 0 1 0 1 0 0 0 "13" 1 1 0 1 1 1 0 1 1 1 0 0 1 0 "14" 1 1 1 1 1 1 1 0 1 0 0 0 1 0 "15" 2 1 0 1 1 1 0 1 0 0 1 1 1 0 "16" 1 1 0 1 0 0 0 1 0 1 1 0 1 0 "17" 1 0 1 1 1 1 1 0 1 1 0 0 1 0 "18" 2 1 1 1 1 0 0 0 0 0 1 0 0 0 "19" 1 0 0 1 1 0 1 1 1 0 1 0 1 0 "20" 3 1 0 1 1 0 1 0 1 0 0 0 1 1 "21" 2 1 0 0 1 0 0 0 0 0 1 0 0 1 "22" 1 0 0 1 1 1 1 1 1 0 1 0 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1 1 "55" 2 1 0 0 1 0 0 1 1 0 1 1 0 0 "56" 2 1 0 0 1 0 0 1 1 0 1 1 0 1 "57" 2 1 1 0 1 0 0 1 1 1 0 1 1 1 "58" 3 1 1 0 1 0 0 0 0 0 0 0 1 0 "59" 3 1 1 0 1 0 0 0 0 0 0 0 1 0 "60" 1 1 0 1 1 0 0 0 0 1 1 0 1 0 "61" 1 1 1 0 0 0 0 0 0 0 1 1 1 1 "62" 2 1 1 0 1 0 0 1 0 1 1 1 0 1 "63" 2 1 1 1 1 0 0 1 0 0 1 0 1 1 "64" 2 1 1 1 1 0 0 1 0 0 1 0 1 1 "65" 1 1 0 1 0 1 1 0 1 1 0 0 1 0 "66" 2 1 1 0 1 0 0 1 0 1 1 1 0 0 "67" 2 1 0 0 1 0 0 0 0 0 1 0 1 0 "68" 2 1 1 0 1 0 0 0 0 0 1 0 0 0 "69" 2 1 1 0 1 0 0 1 1 0 1 1 1 1 "70" 1 1 0 0 1 1 0 0 0 0 0 0 1 1 "71" 3 1 1 0 1 0 0 0 1 0 0 1 1 1 "72" 3 1 0 1 1 1 0 0 1 1 0 0 0 0
This mostly happens when the data contain invalid column names (such as all numbers). Try using make.names() on the datasets. Max On Oct 30, 2011, at 11:35 AM, Luisa S?co <luisa.seco at gmail.com> wrote:> Dear users, > > I'm using rpart for classification trees, but my code isn't working when I > try to use all the variables in my data frame. This data frame was created > from a data frame with 1775 variables, but I choose only 13. > > arv13<-rpart(iv~.,data=gn,method="class",parms=list(split="information")) > > #Error: > > Error in `[.data.frame`(frame, predictors) : undefined columns selected > > "gn" is a data.frame, so I don't understand where is my mistake. > > If I read the data.frame from a txt file "g13.txt" previously saved, > instead creating the data.frame "gn" from the data frame with 1775 > variables (columns), it works. > > My question is: which properties must the data file have to use rpart doing > "iv ~ ." ? > > Thank you very much, > > My best regards > > Lu?sa S?co > <g13.txt> > ______________________________________________ > 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.
Seemingly Similar Threads
- [cfe-dev] GN build roundtable summary; adding GN build files to the repo
- [cfe-dev] GN build roundtable summary; adding GN build files to the repo
- [cfe-dev] GN build roundtable summary; adding GN build files to the repo
- [cfe-dev] GN build roundtable summary; adding GN build files to the repo
- problem running a function