diff --git a/DESCRIPTION b/DESCRIPTION index 727772bb2..213aaf15a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.0.0.9003 +Version: 1.0.0.9004 Date: 2020-02-21 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 1e17777c1..0aa54ceda 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.0.0.9003 +# AMR 1.0.0.9004 ## Last updated: 21-Feb-2020 ### Changed diff --git a/R/data.R b/R/data.R index 183032091..4b4c65de6 100755 --- a/R/data.R +++ b/R/data.R @@ -161,6 +161,18 @@ catalogue_of_life <- list( #' @inheritSection AMR Read more on our website! "example_isolates" +#' Data set with unclean data +#' +#' A data set containing 3,000 microbial isolates that are not cleaned up and consequently not really for AMR analysis. This data set can be used for practice. +#' @format A [`data.frame`] with 3,000 observations and 8 variables: +#' - `patient_id`\cr ID of the patient +#' - `date`\cr date of receipt at the laboratory +#' - `hospital`\cr ID of the hospital, from A to C +#' - `bacteria`\cr info about microorganism that can be transformed with [as.mo()], see also [microorganisms] +#' - `AMX:GEN`\cr 4 different antibiotics that have to be transformed with [as.rsi()] +#' @inheritSection AMR Read more on our website! +"example_isolates_unclean" + #' Data set with 500 isolates - WHONET example #' #' This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The data itself was based on our [example_isolates] data set. diff --git a/data-raw/reproduction_of_example_isolates_unclean.R b/data-raw/reproduction_of_example_isolates_unclean.R new file mode 100644 index 000000000..9d34e990c --- /dev/null +++ b/data-raw/reproduction_of_example_isolates_unclean.R @@ -0,0 +1,94 @@ +# ==================================================================== # +# TITLE # +# Antimicrobial Resistance (AMR) Analysis # +# # +# SOURCE # +# https://gitlab.com/msberends/AMR # +# # +# LICENCE # +# (c) 2018-2020 Berends MS, Luz CF et al. # +# # +# This R package is free software; you can freely use and distribute # +# it for both personal and commercial purposes under the terms of the # +# GNU General Public License version 2.0 (GNU GPL-2), as published by # +# the Free Software Foundation. # +# # +# We created this package for both routine data analysis and academic # +# research and it was publicly released in the hope that it will be # +# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. # +# Visit our website for more info: https://msberends.gitlab.io/AMR. # +# ==================================================================== # + +patients <- unlist(lapply(LETTERS, paste0, 1:10)) + +patients_table <- data.frame(patient_id = patients, + gender = c(rep("M", 135), + rep("F", 125))) + +dates <- seq(as.Date("2011-01-01"), as.Date("2020-01-01"), by = "day") + +bacteria_a <- c("E. coli", "S. aureus", + "S. pneumoniae", "K. pneumoniae") + +bacteria_b <- c("esccol", "staaur", "strpne", "klepne") + +bacteria_c <- c("Escherichia coli", "Staphylococcus aureus", + "Streptococcus pneumoniae", "Klebsiella pneumoniae") + +ab_interpretations <- c("S", "I", "R") + +ab_interpretations_messy = c("R", "< 0.5 S", "I") + +sample_size <- 1000 + +data_a <- data.frame(date = sample(dates, size = sample_size, replace = TRUE), + hospital = "A", + bacteria = sample(bacteria_a, size = sample_size, replace = TRUE, + prob = c(0.50, 0.25, 0.15, 0.10)), + AMX = sample(ab_interpretations, size = sample_size, replace = TRUE, + prob = c(0.60, 0.05, 0.35)), + AMC = sample(ab_interpretations, size = sample_size, replace = TRUE, + prob = c(0.75, 0.10, 0.15)), + CIP = sample(ab_interpretations, size = sample_size, replace = TRUE, + prob = c(0.80, 0.00, 0.20)), + GEN = sample(ab_interpretations, size = sample_size, replace = TRUE, + prob = c(0.92, 0.00, 0.08))) + + +data_b <- data.frame(date = sample(dates, size = sample_size, replace = TRUE), + hospital = "B", + bacteria = sample(bacteria_b, size = sample_size, replace = TRUE, + prob = c(0.50, 0.25, 0.15, 0.10)), + AMX = sample(ab_interpretations_messy, size = sample_size, replace = TRUE, + prob = c(0.60, 0.05, 0.35)), + AMC = sample(ab_interpretations_messy, size = sample_size, replace = TRUE, + prob = c(0.75, 0.10, 0.15)), + CIP = sample(ab_interpretations_messy, size = sample_size, replace = TRUE, + prob = c(0.80, 0.00, 0.20)), + GEN = sample(ab_interpretations_messy, size = sample_size, replace = TRUE, + prob = c(0.92, 0.00, 0.08))) + +data_c <- data.frame(date = sample(dates, size = sample_size, replace = TRUE), + hospital = "C", + bacteria = sample(bacteria_c, size = sample_size, replace = TRUE, + prob = c(0.50, 0.25, 0.15, 0.10)), + AMX = sample(ab_interpretations, size = sample_size, replace = TRUE, + prob = c(0.60, 0.05, 0.35)), + AMC = sample(ab_interpretations, size = sample_size, replace = TRUE, + prob = c(0.75, 0.10, 0.15)), + CIP = sample(ab_interpretations, size = sample_size, replace = TRUE, + prob = c(0.80, 0.00, 0.20)), + GEN = sample(ab_interpretations, size = sample_size, replace = TRUE, + prob = c(0.92, 0.00, 0.08))) + + +example_isolates_unclean <- data_a %>% + bind_rows(data_b, data_c) + +example_isolates_unclean$patient_id <- sample(patients, size = nrow(example_isolates_unclean), replace = TRUE) + +example_isolates_unclean <- example_isolates_unclean %>% + select(patient_id, hospital, date, bacteria, everything()) + +usethis::use_data(example_isolates_unclean, overwrite = TRUE) + diff --git a/data/example_isolates_unclean.rda b/data/example_isolates_unclean.rda new file mode 100644 index 000000000..d15c0393e Binary files /dev/null and b/data/example_isolates_unclean.rda differ diff --git a/docs/404.html b/docs/404.html index 0b45f7dc4..412f36d9e 100644 --- a/docs/404.html +++ b/docs/404.html @@ -78,7 +78,7 @@
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 7ef89b7ab..c2ef2b190 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@ diff --git a/docs/articles/index.html b/docs/articles/index.html index a6853f395..6c2231f88 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -78,7 +78,7 @@ diff --git a/docs/authors.html b/docs/authors.html index 1e94e3d95..87a9651c3 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -78,7 +78,7 @@ diff --git a/docs/index.html b/docs/index.html index cf3f65747..c8d397a0a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ diff --git a/docs/news/index.html b/docs/news/index.html index 19ada7219..8cf9bcb1c 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -78,7 +78,7 @@ @@ -219,9 +219,9 @@ -