1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-09 18:22:02 +02:00

as.mo improvements

This commit is contained in:
2019-02-25 15:52:32 +01:00
parent 0ec76cfa98
commit c506d2893b
13 changed files with 390 additions and 376 deletions

20
R/zzz.R
View File

@ -30,6 +30,10 @@
microorganisms.oldDT <- as.data.table(AMR::microorganisms.old)
setkey(microorganisms.oldDT, col_id, fullname)
assign(x = "microorganisms",
value = make(),
envir = asNamespace("AMR"))
assign(x = "microorganismsDT",
value = make_DT(),
envir = asNamespace("AMR"))
@ -45,9 +49,8 @@
}
#' @importFrom dplyr mutate case_when
#' @importFrom data.table as.data.table setkey
make_DT <- function() {
microorganismsDT <- AMR::microorganisms %>%
make <- function() {
AMR::microorganisms %>%
mutate(prevalence = case_when(
class == "Gammaproteobacteria"
| genus %in% c("Enterococcus", "Staphylococcus", "Streptococcus")
@ -71,11 +74,16 @@ make_DT <- function() {
"Prevotella",
"Rhodotorula",
"Treponema",
"Trichophyton")
"Trichophyton",
"Ureaplasma")
~ 2,
TRUE ~ 3
)) %>%
as.data.table()
))
}
#' @importFrom data.table as.data.table setkey
make_DT <- function() {
microorganismsDT <- as.data.table(make())
setkey(microorganismsDT,
kingdom,
prevalence,