mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 19:41:49 +02:00
unit tests
This commit is contained in:
@ -19,7 +19,7 @@ files <- files[files %unlike% "(zzz|init)[.]R$"]
|
||||
files <- files[files %unlike% "/(between|coalesce|cumulative|fill|glimpse|group_cols|na_if|near|nest_by|check_filter|poorman-package|print|recode|reconstruct|replace_na|replace_with|rownames|slice|union_all|unite|window_rank|with_groups)[.]R$"]
|
||||
|
||||
# add our prepend file, containing info about the source of the data
|
||||
intro <- readLines("data-raw/poorman_prepend.R") %>%
|
||||
intro <- readLines("data-raw/poorman_prepend.R") %>%
|
||||
# add commit to intro part
|
||||
gsub("{commit}", commit, ., fixed = TRUE) %>%
|
||||
# add date to intro part
|
||||
@ -56,7 +56,6 @@ for (use in has_usemethods) {
|
||||
}
|
||||
# add pm_ prefix
|
||||
contents[relevant_row - 1] <- paste0("pm_", contents[relevant_row - 1])
|
||||
|
||||
}
|
||||
# correct for NextMethod
|
||||
contents <- gsub("NextMethod\\(\"(.*)\"\\)", "\\1.data.frame(...)", contents)
|
||||
@ -92,7 +91,7 @@ contents <- contents[trimws(contents) != ""]
|
||||
contents <- gsub("if (!missing(.before))", "if (!missing(.before) && !is.null(.before))", contents, fixed = TRUE)
|
||||
contents <- gsub("if (!missing(.after))", "if (!missing(.after) && !is.null(.after))", contents, fixed = TRUE)
|
||||
contents[which(contents %like% "reshape\\($") + 1] <- gsub("data", "as.data.frame(data, stringsAsFactors = FALSE)", contents[which(contents %like% "reshape\\($") + 1])
|
||||
contents <- gsub('pm_relocate(.data = long, values_to, .after = -1)', 'pm_relocate(.data = long, "value", .after = -1)', contents, fixed = TRUE)
|
||||
contents <- gsub("pm_relocate(.data = long, values_to, .after = -1)", 'pm_relocate(.data = long, "value", .after = -1)', contents, fixed = TRUE)
|
||||
|
||||
# who needs US spelling?
|
||||
contents <- contents[contents %unlike% "summarize"]
|
||||
|
@ -1,26 +1,30 @@
|
||||
|
||||
snomed2 <- microorganisms %>% filter(mo %in% c("B_SLMNL_TYPH", "B_SLMNL_HMRM", "B_SLMNL_PRTY")) %>%
|
||||
snomed2 <- microorganisms %>%
|
||||
filter(mo %in% c("B_SLMNL_TYPH", "B_SLMNL_HMRM", "B_SLMNL_PRTY")) %>%
|
||||
pull(snomed)
|
||||
|
||||
new_typhi <- microorganisms %>%
|
||||
filter(mo == "B_SLMNL_THSS") %>%
|
||||
slice(c(1,1, 1)) %>%
|
||||
mutate(mo = c("B_SLMNL_TYPH", "B_SLMNL_HMRM", "B_SLMNL_PRTY"),
|
||||
fullname = c("Salmonella Typhi", "Salmonella Typhimurium", "Salmonella Paratyphi"),
|
||||
subspecies = c("Typhi", "Typhimurium", "Paratyphi"),
|
||||
snomed = snomed2)
|
||||
filter(mo == "B_SLMNL_THSS") %>%
|
||||
slice(c(1, 1, 1)) %>%
|
||||
mutate(
|
||||
mo = c("B_SLMNL_TYPH", "B_SLMNL_HMRM", "B_SLMNL_PRTY"),
|
||||
fullname = c("Salmonella Typhi", "Salmonella Typhimurium", "Salmonella Paratyphi"),
|
||||
subspecies = c("Typhi", "Typhimurium", "Paratyphi"),
|
||||
snomed = snomed2
|
||||
)
|
||||
|
||||
new_groupa <- microorganisms %>%
|
||||
filter(mo == "B_SLMNL_GRPB") %>%
|
||||
mutate(mo = "B_SLMNL_GRPA",
|
||||
fullname = gsub("roup B", "roup A", fullname),
|
||||
species = gsub("roup B", "roup A", species))
|
||||
filter(mo == "B_SLMNL_GRPB") %>%
|
||||
mutate(
|
||||
mo = "B_SLMNL_GRPA",
|
||||
fullname = gsub("roup B", "roup A", fullname),
|
||||
species = gsub("roup B", "roup A", species)
|
||||
)
|
||||
|
||||
microorganisms$mo <- as.character(microorganisms$mo)
|
||||
|
||||
microorganisms <- microorganisms %>%
|
||||
filter(!mo %in% c("B_SLMNL_TYPH", "B_SLMNL_HMRM", "B_SLMNL_PRTY")) %>%
|
||||
bind_rows(new_typhi, new_groupa) %>%
|
||||
filter(!mo %in% c("B_SLMNL_TYPH", "B_SLMNL_HMRM", "B_SLMNL_PRTY")) %>%
|
||||
bind_rows(new_typhi, new_groupa) %>%
|
||||
arrange(fullname)
|
||||
|
||||
microorganisms$lpsn_parent[which(microorganisms$genus == "Salmonella" & microorganisms$rank == "species")] <- "516547"
|
||||
|
Reference in New Issue
Block a user