R/assignMethods.R

Defines functions .assignMethods

.assignMethods <- function(methods, type, assignEnvir, dispatch_names, mask = FALSE){
  apply(methods, 1, function(amethod){
    if(type == "fun" & mask | type == "fun" & !amethod[[4]])
      method = amethod[[1]]
    else
      method = paste(amethod[[1]], dispatch_names, sep=".")

    value = function(){}
    x = alist(x=)
    names(x) = amethod[[5]]
    formals(value) = c(x,formals(amethod[[2]]))
    body(value) = amethod[[6]][[1]]
    if(type %in% c("S3", "fun"))
      sapply(method, function(x) assign(paste0(x), value, envir = assignEnvir))
    else if(type == "S4")
      sapply(dispatch_names, function(x){
        methods::setOldClass(x, where = assignEnvir)
        methods::setMethod(amethod[[1]], x, def = value, where = assignEnvir)
      })
  })

}

Try the R62S3 package in your browser

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

R62S3 documentation built on March 13, 2020, 3:29 a.m.