R/VarImp.R

Defines functions is.VarImp as.VarImp.numeric as.VarImp.matrix as.VarImp.data.frame as.VarImp

Documented in as.VarImp as.VarImp.data.frame as.VarImp.matrix as.VarImp.numeric is.VarImp

## Object of class 'VarImp'


## as.VarImp
as.VarImp <- function(object, ...)
   UseMethod("as.VarImp")

as.VarImp.data.frame <- function(object, FUN = mean,
                             type = c("Permutation", "Conditional Permutation", "Selection Frequency", "See Info"), 
                             info = NULL, ...)
{
   match.fun(FUN)
   out <- list(values = apply(object, 2, FUN, ...),
               perTree = object,
               type = match.arg(type),
               info = info)
   class(out) <- "VarImp"
   return(out)
}

as.VarImp.matrix <- function(object, FUN = mean,
                                 type = c("Permutation", "Conditional Permutation", "Selection Frequency", "See Info"), 
                                 info = NULL, ...)
{
   object <- as.data.frame(object)
   as.VarImp(object, FUN, type, info, ...)
}

as.VarImp.numeric <- function(object, perTree = NULL,
                              type = c("Permutation", "Conditional Permutation", "Selection Frequency", "See Info"), 
                              info = NULL, ...)
{
   out <- list(values = object,
               perTree = perTree,
               type = match.arg(type),
               info = info)
   class(out) <- "VarImp"
   return(out)
}

## is.VarImp
is.VarImp <- function(VarImp)
{
   names <- all(c("values", "perTree", "type", "info") %in% names(VarImp))
   all(names, class(VarImp) == "VarImp")
}

Try the permimp package in your browser

Any scripts or data that you put into this service are public.

permimp documentation built on Sept. 14, 2021, 1:07 a.m.