It is isn't easy to write code that works with column names that have spaces. 
You could rewrite rpart, or just rename the columns in your data frame to work 
around the "bug". See ?names.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnew...@dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Raji <raji.sanka...@gmail.com> wrote:

>Hi,
>
>Our data has column names with spaces in that.The names in dataFrame
>are,
>    *[1] "Sepal Length" "Sepal Width"  "Petal Length" "Petal Width" 
>"Species" *
>When i try to use the column names in rpart function, it gives the
>following
>error.
>*   rp<-rpart(as.factor(`Species`)~`Sepal Length`)
>Error in `[.data.frame`(frame, predictors) : undefined columns
>selected*
>
>But , a similar call works for kmeans/nnet functions.For example,
>  *nn<-nnet(as.factor(`Species`)~`Sepal Length`,size=3)*
>
>Is there any way in which column names with spaces be used in rpart
>function
>like being used in nnet/kmeans function?
>
>Thanks in advance for your help,
>Raji
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/rpart-space-in-column-names-tp4631557.html
>Sent from the R help mailing list archive at Nabble.com.
>
>______________________________________________
>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.

______________________________________________
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