[R] Rpart -- using predict() when missing data is present?

From: Ajay Narottam Shah <ajayshah_at_mayin.org>
Date: Sun 09 Oct 2005 - 02:38:49 EST

I am doing

> library(rpart)
> m <- rpart("y ~ x", D[insample,])
> D[outsample,]

            y x
8 0.78391922 0.579025591

9  0.06629211          NA
10         NA 0.001593063

> p <- predict(m, newdata=D[9,])

Error in model.frame(formula, rownames, variables, varnames, extras, extranames, :

        invalid result from na.action

How do I persuade him to give me NA since x is NA?

I looked at ?predict.rpart but didn't find any mention about NAs.

(In this problem, I can easily do it manually, but this is a part of something bigger where I want him to be able to gracefully handle prediction requests involving NA).

Ajay Shah                                                   Consultant
ajayshah@mayin.org                      Department of Economic Affairs
http://www.mayin.org/ajayshah           Ministry of Finance, New Delhi

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sun Oct 09 02:43:39 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:40 EST