1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-27 06:06:12 +01:00
AMR/data-raw/internals.R

58 lines
2.4 KiB
R
Raw Normal View History

# Run this file to update the package -------------------------------------
# source("data-raw/internals.R")
# See 'data-raw/eucast_rules.tsv' for the EUCAST reference file
2019-06-01 20:40:49 +02:00
eucast_rules_file <- dplyr::arrange(
.data = utils::read.delim(file = "data-raw/eucast_rules.tsv",
skip = 10,
2019-06-01 20:40:49 +02:00
sep = "\t",
stringsAsFactors = FALSE,
header = TRUE,
strip.white = TRUE,
na = c(NA, "", NULL)),
reference.rule_group,
reference.rule)
# Translations ----
translations_file <- utils::read.delim(file = "data-raw/translations.tsv",
2019-06-01 20:40:49 +02:00
sep = "\t",
stringsAsFactors = FALSE,
header = TRUE,
blank.lines.skip = TRUE,
fill = TRUE,
strip.white = TRUE,
encoding = "UTF-8",
fileEncoding = "UTF-8",
na.strings = c(NA, "", NULL),
allowEscapes = TRUE, # else "\\1" will be imported as "\\\\1"
quote = "")
2019-06-01 20:40:49 +02:00
2019-09-18 15:46:09 +02:00
# Old microorganism codes -------------------------------------------------
microorganisms.translation <- readRDS("data-raw/microorganisms.translation.rds")
2019-06-01 20:40:49 +02:00
# Export to package as internal data ----
2019-09-18 15:46:09 +02:00
usethis::use_data(eucast_rules_file, translations_file, microorganisms.translation,
2019-06-01 20:40:49 +02:00
internal = TRUE,
overwrite = TRUE,
version = 2)
# Remove from global environment ----
rm(eucast_rules_file)
rm(translations_file)
2019-09-18 15:46:09 +02:00
rm(microorganisms.translation)
# Clean mo history ----
2019-09-22 17:19:59 +02:00
usethis::ui_done(paste0("Resetting {usethis::ui_value('mo_history.csv')}"))
tryCatch(
write.csv(x = data.frame(x = character(0),
mo = character(0),
uncertainty_level = integer(0),
2019-09-22 17:19:59 +02:00
package_version = character(0),
stringsAsFactors = FALSE),
2019-09-22 17:19:59 +02:00
row.names = FALSE,
file = "inst/mo_history/mo_history.csv"),
warning = function(w) cat("Warning:", w$message, "\n"),
error = function(e) cat("Error:", e$message, "\n"))