[R] rpart error message
David Winsemius
dwinsemius at comcast.net
Tue Apr 3 15:16:27 CEST 2012
On Apr 3, 2012, at 4:16 AM, Raji wrote:
> Hi R-helpers,
> I am using rpart package for decision tree using R.We are invoking R
> environment through JRI from our java application.Hence, the result
> of R
> command is returned in REXP and we use geterrMessage() to retrieve the
> error.
>
> When we execute the following command,
>
> cnr_model<-rpart(as.factor(Species)~Sepal Length+Sepal Width+Petal
> Length,
You have spaces in your variable names. That has nothing to do with
JRI and everything to do with base R syntax.
(You also have no data argument so are you attaching it. That would
seem to be an unwise choice.)
> method="class", parms=list(split="gini",prior=c()),
> control=rpart.control(minsplit=2,
> na
> .action
> =
> na
> .pass
> ,cp
> =
> 0.001
> ,usesurrogate=1,maxsurrogate=2,surrogatestyle=0,maxdepth=20,xval=10))
>
> we get an error message* "Error: unexpected symbol in
> "a<-cnr_model<-rpart(as.factor(Species)~Sepal Length""*
The unexpected symbol was "Length". Spaces are separators to the R
parser.
>
> The REXP returned in not null and the geterrMessage() call doesnt
> return an
> error message.
>
> But for other errors in R , say "summary(cnr_model)" , REXP returned
> is null
> and we get the following error message from geterrMessage() call.
>
> *Error in summary(cnr_model) : object 'cnr_model' not found*
Right. It wasn't found because the command you tried to create it
with ... failed.
>
> Is this behavior of showing error message specific to rpart package ?
No. It would be very generic.
> Why is
> this difference in the way error message is displayed in rpart
> package?Can
> you please let us know how to retrieve error messages of rpart command
> through JRI?
>
> Thanks in advance.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/rpart-error-message-tp4528104p4528104.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list