diff --git a/DESCRIPTION b/DESCRIPTION index 727772bb..213aaf15 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 1e17777c..0aa54ced 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 18303209..4b4c65de 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 00000000..9d34e990 --- /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 00000000..d15c0393 Binary files /dev/null and b/data/example_isolates_unclean.rda differ diff --git a/docs/404.html b/docs/404.html index 0b45f7dc..412f36d9 100644 --- a/docs/404.html +++ b/docs/404.html @@ -78,7 +78,7 @@ AMR (for R) - 1.0.0.9003 + 1.0.0.9004 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 7ef89b7a..c2ef2b19 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@ AMR (for R) - 1.0.0.9003 + 1.0.0.9004 diff --git a/docs/articles/index.html b/docs/articles/index.html index a6853f39..6c2231f8 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -78,7 +78,7 @@ AMR (for R) - 1.0.0.9003 + 1.0.0.9004 diff --git a/docs/authors.html b/docs/authors.html index 1e94e3d9..87a9651c 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -78,7 +78,7 @@ AMR (for R) - 1.0.0.9003 + 1.0.0.9004 diff --git a/docs/index.html b/docs/index.html index cf3f6574..c8d397a0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.0.0.9003 + 1.0.0.9004 diff --git a/docs/news/index.html b/docs/news/index.html index 19ada721..8cf9bcb1 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -78,7 +78,7 @@ AMR (for R) - 1.0.0.9003 + 1.0.0.9004 @@ -219,9 +219,9 @@ -
+

-AMR 1.0.0.9003 Unreleased +AMR 1.0.0.9004 Unreleased

@@ -1473,7 +1473,7 @@

Contents

diff --git a/docs/sitemap.xml b/docs/sitemap.xml index bd7546b2..d895ebc0 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -66,6 +66,9 @@ https://msberends.gitlab.io/AMR/reference/example_isolates.html + + https://msberends.gitlab.io/AMR/reference/example_isolates_unclean.html + https://msberends.gitlab.io/AMR/reference/extended-functions.html diff --git a/man/example_isolates_unclean.Rd b/man/example_isolates_unclean.Rd new file mode 100644 index 00000000..67226586 --- /dev/null +++ b/man/example_isolates_unclean.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{example_isolates_unclean} +\alias{example_isolates_unclean} +\title{Data set with unclean data} +\format{A \code{\link{data.frame}} with 3,000 observations and 8 variables: +\itemize{ +\item \code{patient_id}\cr ID of the patient +\item \code{date}\cr date of receipt at the laboratory +\item \code{hospital}\cr ID of the hospital, from A to C +\item \code{bacteria}\cr info about microorganism that can be transformed with \code{\link[=as.mo]{as.mo()}}, see also \link{microorganisms} +\item \code{AMX:GEN}\cr 4 different antibiotics that have to be transformed with \code{\link[=as.rsi]{as.rsi()}} +}} +\usage{ +example_isolates_unclean +} +\description{ +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. +} +\section{Read more on our website!}{ + +On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. +} + +\keyword{datasets} diff --git a/tests/testthat/test-rsi.R b/tests/testthat/test-rsi.R index 46dd1be8..f55a7ff3 100644 --- a/tests/testthat/test-rsi.R +++ b/tests/testthat/test-rsi.R @@ -58,7 +58,7 @@ test_that("rsi works", { sum(), 40) - expect_output(tibble(ab = as.rsi("S"))) + expect_output(print(tibble(ab = as.rsi("S")))) expect_error(as.rsi.mic(as.mic(16))) expect_error(as.rsi.disk(as.disk(16)))