Displaying 1 result from an estimated 1 matches for "mfnew".
Did you mean:
fnew
2015 Apr 29
0
model.matrix and na.action
..." ...)
==========
mm <- function(newdata,form=~x,na.action=na.pass,set.opts=FALSE) {
if (set.opts) {
op <- options(na.action=na.action)
on.exit(options(op))
}
## try with raw data and with model.frame with na.action specified
X1 <- model.matrix(form, mfnew <- model.frame(newdata,
na.action=na.action))
X2 <- model.matrix(form, newdata)
return(c(any(is.na(X1[,"x"])),any(is.na(X2[,"x"]))))
}
options("na.action") ## na.omit
d <- data.frame(x=c(NA,NA,1:5))
mm...