Commit eda9e6c1 by Eric Coissac

Implements na.action for procmod.frame

parent d47ce57c
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
na.omit.procmod.frame=function (object, ...)
{
n <- length(object)
omit <- logical(nrow(object))
vars <- seq_len(n)
for (j in vars) {
x <- object[[j]]
omit= omit | rowSums(is.na(x))>0
}
xx <- object[!omit, , drop = FALSE]
if (any(omit > 0L)) {
temp <- setNames(seq(omit)[omit], attr(object, "row.names")[omit])
attr(temp, "class") <- "omit"
attr(xx, "na.action") <- temp
}
return(xx)
}
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
na.exclude.procmod.frame=function(object, ...) {
xx = na.omit.procmod.frame(object, ...)
na.action = attr(xx, "na.action")
if (! is.null(na.action)) {
class(na.action)="exclude"
attr(xx, "na.action")=na.action
}
return(xx)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment