mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 12:31:58 +02:00
(v0.8.0.9031) as.mo() improvements
This commit is contained in:
12
R/zzz.R
12
R/zzz.R
@ -47,15 +47,21 @@
|
||||
# maybe add survey later: "https://www.surveymonkey.com/r/AMR_for_R"
|
||||
|
||||
#' @importFrom data.table as.data.table setkey
|
||||
#' @importFrom dplyr %>% mutate case_when
|
||||
make_DT <- function() {
|
||||
microorganismsDT <- as.data.table(AMR::microorganisms %>%
|
||||
mutate(kingdom_index = case_when(kingdom == "Bacteria" ~ 1,
|
||||
kingdom == "Fungi" ~ 2,
|
||||
kingdom == "Protozoa" ~ 3,
|
||||
kingdom == "Archaea" ~ 4,
|
||||
TRUE ~ 6)))
|
||||
# for fullname_lower: keep only dots, letters, numbers, slashes, spaces and dashes
|
||||
microorganismsDT$fullname_lower <- gsub("[^.a-z0-9/ \\-]+", "", tolower(microorganismsDT$fullname))
|
||||
TRUE ~ 99),
|
||||
# for fullname_lower: keep only dots, letters,
|
||||
# numbers, slashes, spaces and dashes
|
||||
fullname_lower = gsub("[^.a-z0-9/ \\-]+", "",
|
||||
# use this paste instead of `fullname` to
|
||||
# work with Viridans Group Streptococci, etc.
|
||||
tolower(trimws(paste(genus, species, subspecies))))))
|
||||
# so arrange data on prevalence first, then kingdom, then full name
|
||||
setkey(microorganismsDT,
|
||||
prevalence,
|
||||
kingdom_index,
|
||||
|
Reference in New Issue
Block a user