1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 11:11:54 +02:00

as.mo speedup: assigned to namespace

This commit is contained in:
2018-10-29 17:26:17 +01:00
parent b4e71cdc4f
commit 1bf8dc2983
5 changed files with 61 additions and 53 deletions

25
R/zzz.R
View File

@ -18,7 +18,7 @@
#' The \code{AMR} Package
#'
#' Welcome to the \code{AMR} package. This page gives some additional contact information abount the authors.
#' Welcome to the \code{AMR} package. This page gives some additional contact information about the authors.
#' @details
#' This package was intended to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and work with antibiotic properties by using evidence-based methods.
#'
@ -39,7 +39,7 @@
#' 9700 RB Groningen
#'
#' If you have found a bug, please file a new issue at: \cr
#' \url{https://github.com/msberends/AMR/issues}
#' \url{https://gitlab.com/msberends/AMR/issues}
#' @name AMR
#' @rdname AMR
NULL
@ -47,3 +47,24 @@ NULL
.onLoad <- function(libname, pkgname) {
backports::import(pkgname)
}
.onAttach <- function(libname, pkgname) {
# save data.tables to improve speed of as.mo:
MOs <- data.table::as.data.table(AMR::microorganisms)
data.table::setkey(MOs, prevalence, tsn)
base::assign(x = "MOs",
value = MOs,
envir = base::as.environment("package:AMR"))
base::assign(x = "MOs_mostprevalent",
value = MOs[prevalence != 9999,],
envir = base::as.environment("package:AMR"))
base::assign(x = "MOs_allothers",
value = MOs[prevalence == 9999,],
envir = base::as.environment("package:AMR"))
base::assign(x = "MOs_old",
value = data.table::as.data.table(AMR::microorganisms.old),
envir = base::as.environment("package:AMR"))
}