From 6fa05fe33bfd0ee8a8bbcc0c93c5c0f718827f27 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Mon, 26 Feb 2018 14:06:31 +0100 Subject: [PATCH] first isolates --- R/first_isolates.R | 19 +++++++++++-------- README.md | 10 +++++----- man/first_isolate.Rd | 4 ++-- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/R/first_isolates.R b/R/first_isolates.R index efc67f0b..cc8c999e 100644 --- a/R/first_isolates.R +++ b/R/first_isolates.R @@ -21,7 +21,7 @@ #' Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. #' @param tbl a \code{data.frame} containing isolates. #' @param col_date column name of the result date (or date that is was received on the lab) -#' @param col_patid column name of the unique IDs of the patients +#' @param col_patient_id column name of the unique IDs of the patients #' @param col_genus column name of the genus of the microorganisms #' @param col_species column name of the species of the microorganisms #' @param col_testcode column name of the test codes, see Details @@ -84,7 +84,7 @@ #' } first_isolate <- function(tbl, col_date, - col_patid, + col_patient_id, col_genus, col_species, col_testcode = NA, @@ -113,7 +113,7 @@ first_isolate <- function(tbl, } check_columns_existance(col_date) - check_columns_existance(col_patid) + check_columns_existance(col_patient_id) check_columns_existance(col_genus) check_columns_existance(col_species) check_columns_existance(col_testcode) @@ -162,7 +162,10 @@ first_isolate <- function(tbl, mutate(first_isolate_row_index = 1:nrow(tbl), eersteisolaatbepaling = 0, date_lab = tbl %>% pull(col_date), - species = if_else(is.na(species), '', species), + patient_id = tbl %>% pull(col_patient_id), + species = tbl %>% pull(col_species), + genus = tbl %>% pull(col_genus)) %>% + mutate(species = if_else(is.na(species), '', species), genus = if_else(is.na(genus), '', genus)) if (filter_specimen == '') { @@ -172,7 +175,7 @@ first_isolate <- function(tbl, cat('Isolates from ICU will *NOT* be ignored.\n') } tbl <- tbl %>% - arrange_at(c(col_patid, + arrange_at(c(col_patient_id, col_genus, col_species, col_date)) @@ -184,7 +187,7 @@ first_isolate <- function(tbl, } tbl <- tbl %>% arrange_at(c(col_icu, - col_patid, + col_patient_id, col_genus, col_species, col_date)) @@ -205,7 +208,7 @@ first_isolate <- function(tbl, } tbl <- tbl %>% arrange_at(c(col_specimen, - col_patid, + col_patient_id, col_genus, col_species, col_date)) @@ -222,7 +225,7 @@ first_isolate <- function(tbl, tbl <- tbl %>% arrange_at(c(col_icu, col_specimen, - col_patid, + col_patient_id, col_genus, col_species, col_date)) diff --git a/README.md b/README.md index d5e7a40d..ec2b1a74 100644 --- a/README.md +++ b/README.md @@ -17,17 +17,17 @@ It also contains functions to translate antibiotic codes from the lab (like `"AM This package is available on CRAN (latest stable version) and also here on GitHub (latest development version). -#### Latest stable version from CRAN (recommended) -RStudio: -- Click on `Tools` and then `Install Packages..` +### Latest stable version from CRAN (recommended) +For RStudio: +- Click on `Tools` and then `Install Packages...` - Type in `AMR` and press Install -Other: +Or in the R console: ```r install.packages("AMR") ``` -#### Latest development version from GitHub +### Latest development version from GitHub ```r devtools::install_github("msberends/AMR") ``` diff --git a/man/first_isolate.Rd b/man/first_isolate.Rd index 0ea54ef8..ca9e344d 100644 --- a/man/first_isolate.Rd +++ b/man/first_isolate.Rd @@ -4,7 +4,7 @@ \alias{first_isolate} \title{Determine first (weighted) isolates} \usage{ -first_isolate(tbl, col_date, col_patid, col_genus, col_species, +first_isolate(tbl, col_date, col_patient_id, col_genus, col_species, col_testcode = NA, col_specimen, col_icu, col_keyantibiotics = NA, episode_days = 365, testcodes_exclude = "", icu_exclude = FALSE, filter_specimen = NA, output_logical = TRUE, ignore_I = TRUE, @@ -15,7 +15,7 @@ first_isolate(tbl, col_date, col_patid, col_genus, col_species, \item{col_date}{column name of the result date (or date that is was received on the lab)} -\item{col_patid}{column name of the unique IDs of the patients} +\item{col_patient_id}{column name of the unique IDs of the patients} \item{col_genus}{column name of the genus of the microorganisms}