R/zzz.R

Defines functions register_s3 .onLoad

.onLoad <- function(...) {

  register_s3("coda", "as.mcmc", "bvar")
  register_s3("coda", "as.mcmc", "bvar_chains")
  register_s3("vars", "irf", "bvar")
  register_s3("vars", "irf", "bvar_irf")
  register_s3("vars", "fevd", "bvar")
  register_s3("vars", "fevd", "bvar_irf")
  register_s3("vars", "fevd", "bvar_fevd")

  invisible()
}

register_s3 <- function(pkg, generic, class) {

  fun <- get(paste0(generic, ".", class), envir = parent.frame())
  stopifnot(is.function(fun))

  if(pkg %in% loadedNamespaces()) {
    registerS3method(generic, class, fun, envir = asNamespace(pkg))
  }

  setHook(packageEvent(pkg, "onLoad"), function(...) {
    registerS3method(generic, class, fun, envir = asNamespace(pkg))
  })
}

Try the BVAR package in your browser

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

BVAR documentation built on May 29, 2024, 5:34 a.m.