[R] R function writing question
Rachel Merriman
rachel at stat.auckland.ac.nz
Fri Sep 8 01:27:01 CEST 2000
Hi there!
I'm looking for a better way of getting the following code working --
can you help? Instead of having to type in:
binarymissing(y ~ x1 + x2,data=mydata,na.action=na.keep)
as my function call, I would prefer not having to type in
na.action=na.keep each time as this will always be the same.
The function na.keep is simply: na.keep <- function(X){X}
The first few lines of the function binarymissing are:
binarymissing<- function (formula, surrogates=NULL, data = sys.parent(),
weights,na.action)
{
mf <- match.call()
mf[[1]] <- as.name("model.frame")
mf <- eval(mf, sys.frame(sys.parent()))
Y <- model.extract(mf,response)
Terms <- attr(mf,"terms")
X <- model.matrix(Terms,mf)
...
}
I've tried a few different things that haven't worked: for example if I
put na.action=na.keep on the first line of function as my default,
the match.call line doesn't pick up the na.action value for some
reason. Then when I use model.matrix it strips out all my missing
values (i.e. na.action=na.omit not na.keep) which is not what I want!
Hopefully I have made this problem clear enough to you... I'd really
appreciate your help!
Cheers,
Rachel
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list