mirror of
				https://github.com/msberends/AMR.git
				synced 2025-10-31 06:08:14 +01:00 
			
		
		
		
	(v1.2.0.9023) ab_from_text() improvement
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| Package: AMR | Package: AMR | ||||||
| Version: 1.2.0.9022 | Version: 1.2.0.9023 | ||||||
| Date: 2020-07-01 | Date: 2020-07-02 | ||||||
| Title: Antimicrobial Resistance Analysis | Title: Antimicrobial Resistance Analysis | ||||||
| Authors@R: c( | Authors@R: c( | ||||||
|     person(role = c("aut", "cre"),  |     person(role = c("aut", "cre"),  | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								NEWS.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								NEWS.md
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | |||||||
| # AMR 1.2.0.9022 | # AMR 1.2.0.9023 | ||||||
| ## <small>Last updated: 01-Jul-2020</small> | ## <small>Last updated: 02-Jul-2020</small> | ||||||
|  |  | ||||||
| ### New | ### New | ||||||
| * Function `ab_from_text()` to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses `as.ab()` internally | * Function `ab_from_text()` to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses `as.ab()` internally | ||||||
| @@ -19,9 +19,9 @@ | |||||||
| * Added Monuril as trade name for fosfomycin | * Added Monuril as trade name for fosfomycin | ||||||
|  |  | ||||||
| ### Changed | ### Changed | ||||||
| * Using unexisting columns in all `count_*()`, `proportion_*()`, `susceptibility()` and `resistance()` functions wil now return an error instead of dropping them silently | * Using unexisting columns in all `count_*()`, `proportion_*()`, `susceptibility()` and `resistance()` functions wil now return an error instead of dropping them silently. Using variables for column names (as well as `dplyr::all_of()`) now works again. | ||||||
| * Improvements for `as.ab()`: | * Improvements for `as.ab()`: | ||||||
|   * Dramatic improvement of the algorithm behind `as.ab()`, making many more input errors translatable like from digitalised health care records, using too few or too many vowels or consonants and many more |   * Dramatic improvement of the algorithm behind `as.ab()`, making many more input errors translatable, such as digitalised health care records, using too few or too many vowels or consonants and many more | ||||||
|   * Added progress bar |   * Added progress bar | ||||||
|   * Fixed a bug where `as.ab()` would return an error on invalid input values |   * Fixed a bug where `as.ab()` would return an error on invalid input values | ||||||
|   * The `as.ab()` function will now throw a note if more than 1 antimicrobial drug could be retrieved from a single input value. |   * The `as.ab()` function will now throw a note if more than 1 antimicrobial drug could be retrieved from a single input value. | ||||||
| @@ -32,7 +32,7 @@ | |||||||
| * Fixed a bug in `bug_drug_combinations()` for when only one antibiotic was in the input data | * Fixed a bug in `bug_drug_combinations()` for when only one antibiotic was in the input data | ||||||
| * Changed the summary for class `<mo>`, to highlight the %SI vs. %R | * Changed the summary for class `<mo>`, to highlight the %SI vs. %R | ||||||
| * Improved error handling, giving more useful info when functions return an error | * Improved error handling, giving more useful info when functions return an error | ||||||
|  | * Any progress bar will now only show in interactive mode (i.e. not in R Markdown) | ||||||
|  |  | ||||||
| # AMR 1.2.0 | # AMR 1.2.0 | ||||||
|  |  | ||||||
|   | |||||||
| @@ -27,6 +27,7 @@ | |||||||
| #' @param type type of property to search for, either `"drug"`, `"dose"` or `"administration"`, see *Examples* | #' @param type type of property to search for, either `"drug"`, `"dose"` or `"administration"`, see *Examples* | ||||||
| #' @param collapse character to pass on to `paste(..., collapse = ...)` to only return one character per element of `text`, see *Examples* | #' @param collapse character to pass on to `paste(..., collapse = ...)` to only return one character per element of `text`, see *Examples* | ||||||
| #' @param translate_ab if `type = "drug"`: a column name of the [antibiotics] data set to translate the antibiotic abbreviations to, using [ab_property()]. Defaults to `FALSE`. Using `TRUE` is equal to using "name". | #' @param translate_ab if `type = "drug"`: a column name of the [antibiotics] data set to translate the antibiotic abbreviations to, using [ab_property()]. Defaults to `FALSE`. Using `TRUE` is equal to using "name". | ||||||
|  | #' @param thorough_search logical to indicate whether the input must be extensively searched for misspelling and other faulty input values. Setting this to `TRUE` will take considerably more time than when using `FALSE`. At default, it will turn `TRUE` when all input elements contain a maximum of three words. | ||||||
| #' @param ... parameters passed on to [as.ab()] | #' @param ... parameters passed on to [as.ab()] | ||||||
| #' @details This function is also internally used by [as.ab()], although it then only searches for the first drug name and will throw a note if more drug names could have been returned. | #' @details This function is also internally used by [as.ab()], although it then only searches for the first drug name and will throw a note if more drug names could have been returned. | ||||||
| #'  | #'  | ||||||
| @@ -85,6 +86,7 @@ ab_from_text <- function(text, | |||||||
|                          type = c("drug", "dose", "administration"), |                          type = c("drug", "dose", "administration"), | ||||||
|                          collapse = NULL, |                          collapse = NULL, | ||||||
|                          translate_ab = FALSE, |                          translate_ab = FALSE, | ||||||
|  |                          thorough_search = NULL, | ||||||
|                          ...) { |                          ...) { | ||||||
|    |    | ||||||
|   if (missing(type)) { |   if (missing(type)) { | ||||||
| @@ -95,30 +97,54 @@ ab_from_text <- function(text, | |||||||
|    |    | ||||||
|   text <- tolower(as.character(text)) |   text <- tolower(as.character(text)) | ||||||
|   text_split_all <- strsplit(text, "[ ;.,:\\|]") |   text_split_all <- strsplit(text, "[ ;.,:\\|]") | ||||||
|  |   progress <- progress_estimated(n = length(text_split_all), n_min = 5) | ||||||
|  |   on.exit(close(progress)) | ||||||
|    |    | ||||||
|   if (type %like% "(drug|ab|anti)") { |   if (type %like% "(drug|ab|anti)") { | ||||||
|      |      | ||||||
|     translate_ab <- get_translate_ab(translate_ab) |     translate_ab <- get_translate_ab(translate_ab) | ||||||
|      |      | ||||||
|  |     if (isTRUE(thorough_search) |  | ||||||
|  |         (isTRUE(is.null(thorough_search)) & max(sapply(text_split_all, length), na.rm = TRUE) <= 3)) { | ||||||
|  |       text_split_all <- text_split_all[nchar(text_split_all) >= 4 & grepl("[a-z]+", text_split_all)] | ||||||
|  |       result <- lapply(text_split_all, function(text_split) { | ||||||
|  |         progress$tick() | ||||||
|  |         suppressWarnings( | ||||||
|  |           out <- as.ab(text_split, ...) | ||||||
|  |         ) | ||||||
|  |       }) | ||||||
|  |        | ||||||
|  |     } else { | ||||||
|  |       # no thorough search | ||||||
|       abbr <- unlist(antibiotics$abbreviations) |       abbr <- unlist(antibiotics$abbreviations) | ||||||
|       abbr <- abbr[nchar(abbr) >= 4] |       abbr <- abbr[nchar(abbr) >= 4] | ||||||
|       names_atc <- substr(c(antibiotics$name, antibiotics$atc), 1, 5) |       names_atc <- substr(c(antibiotics$name, antibiotics$atc), 1, 5) | ||||||
|       synonyms <- unlist(antibiotics$synonyms) |       synonyms <- unlist(antibiotics$synonyms) | ||||||
|       synonyms <- synonyms[nchar(synonyms) >= 4] |       synonyms <- synonyms[nchar(synonyms) >= 4] | ||||||
|  |       # regular expression must not be too long, so split synonyms in two: | ||||||
|  |       synonyms_part1 <- synonyms[seq_len(0.5 * length(synonyms))] | ||||||
|  |       synonyms_part2 <- synonyms[!synonyms %in% synonyms_part1] | ||||||
|       to_regex <- function(x) { |       to_regex <- function(x) { | ||||||
|         paste0("^(", |         paste0("^(", | ||||||
|              paste0(unique(gsub("[^a-z0-9]", ".*", sort(tolower(x)))), collapse = "|"), |                paste0(unique(gsub("[^a-z0-9]+", "", sort(tolower(x)))), collapse = "|"), | ||||||
|                ").*") |                ").*") | ||||||
|       } |       } | ||||||
|      |  | ||||||
|       result <- lapply(text_split_all, function(text_split) { |       result <- lapply(text_split_all, function(text_split) { | ||||||
|  |         progress$tick() | ||||||
|         suppressWarnings( |         suppressWarnings( | ||||||
|         out <- as.ab(unique(c(text_split[grep(to_regex(abbr), text_split)], |           out <- as.ab(unique(c(text_split[text_split %like_case% to_regex(abbr)], | ||||||
|                               text_split[grep(to_regex(names_atc), text_split)], |                                 text_split[text_split %like_case% to_regex(names_atc)], | ||||||
|                               # regular expression must not be too long, so split synonyms in two: |                                 text_split[text_split %like_case% to_regex(synonyms_part1)], | ||||||
|                               text_split[grep(to_regex(synonyms[c(1:0.5 * length(synonyms))]), text_split)], |                                 text_split[text_split %like_case% to_regex(synonyms_part2)]) | ||||||
|                               text_split[grep(to_regex(synonyms[c(0.5 * length(synonyms):length(synonyms))]), text_split)])), |                               ), | ||||||
|                      ...)) |                        ...) | ||||||
|  |         ) | ||||||
|  |       }) | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     close(progress) | ||||||
|  |      | ||||||
|  |     result <- lapply(result, function(out) { | ||||||
|       out <- out[!is.na(out)] |       out <- out[!is.na(out)] | ||||||
|       if (length(out) == 0) { |       if (length(out) == 0) { | ||||||
|         as.ab(NA) |         as.ab(NA) | ||||||
| @@ -128,6 +154,7 @@ ab_from_text <- function(text, | |||||||
|         } |         } | ||||||
|         out |         out | ||||||
|       } |       } | ||||||
|  |        | ||||||
|     }) |     }) | ||||||
|      |      | ||||||
|   } else if (type %like% "dos") { |   } else if (type %like% "dos") { | ||||||
| @@ -167,7 +194,7 @@ ab_from_text <- function(text, | |||||||
|   # collapse text if needed |   # collapse text if needed | ||||||
|   if (!is.null(collapse)) { |   if (!is.null(collapse)) { | ||||||
|     result <- sapply(result, function(x) { |     result <- sapply(result, function(x) { | ||||||
|       if(length(x) == 1 & all(is.na(x))) { |       if (length(x) == 1 & all(is.na(x))) { | ||||||
|         NA_character_ |         NA_character_ | ||||||
|       } else { |       } else { | ||||||
|         paste0(x, collapse = collapse) |         paste0(x, collapse = collapse) | ||||||
|   | |||||||
| @@ -135,7 +135,7 @@ format.bug_drug_combinations <- function(x, | |||||||
|     format <- tolower(format) |     format <- tolower(format) | ||||||
|     ab_txt <- rep(format, length(ab)) |     ab_txt <- rep(format, length(ab)) | ||||||
|     for (i in seq_len(length(ab_txt))) { |     for (i in seq_len(length(ab_txt))) { | ||||||
|       ab_txt[i] <- gsub("ab", ab[i], ab_txt[i]) |       ab_txt[i] <- gsub("ab", as.character(as.ab(ab[i])), ab_txt[i]) | ||||||
|       ab_txt[i] <- gsub("cid", ab_cid(ab[i]), ab_txt[i]) |       ab_txt[i] <- gsub("cid", ab_cid(ab[i]), ab_txt[i]) | ||||||
|       ab_txt[i] <- gsub("group", ab_group(ab[i], language = language), ab_txt[i]) |       ab_txt[i] <- gsub("group", ab_group(ab[i], language = language), ab_txt[i]) | ||||||
|       ab_txt[i] <- gsub("atc_group1", ab_atc_group1(ab[i], language = language), ab_txt[i]) |       ab_txt[i] <- gsub("atc_group1", ab_atc_group1(ab[i], language = language), ab_txt[i]) | ||||||
|   | |||||||
| @@ -322,13 +322,13 @@ first_isolate <- function(x, | |||||||
|                                FALSE, |                                FALSE, | ||||||
|                                TRUE) |                                TRUE) | ||||||
|   x$episode_group <- paste(x$newvar_patient_id, x$newvar_genus_species) |   x$episode_group <- paste(x$newvar_patient_id, x$newvar_genus_species) | ||||||
|   x$more_than_episode_ago <- unname(unlist(lapply(unique(x$episode_group),  |   x$more_than_episode_ago <- unlist(lapply(unique(x$episode_group), | ||||||
|                                            function(g, |                                            function(g, | ||||||
|                                                     df = x, |                                                     df = x, | ||||||
|                                                     days = episode_days) { |                                                     days = episode_days) { | ||||||
|                                                             identify_new_year(x = df[which(df$episode_group == g), "newvar_date"], |                                              identify_new_year(x = df[which(df$episode_group == g), "newvar_date", drop = TRUE], | ||||||
|                                                                episode_days = days) |                                                                episode_days = days) | ||||||
|                                                           }))) |                                            })) | ||||||
|    |    | ||||||
|   weighted.notice <- "" |   weighted.notice <- "" | ||||||
|   if (!is.null(col_keyantibiotics)) { |   if (!is.null(col_keyantibiotics)) { | ||||||
|   | |||||||
							
								
								
									
										13
									
								
								R/like.R
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								R/like.R
									
									
									
									
									
								
							| @@ -102,14 +102,19 @@ like <- function(x, pattern, ignore.case = TRUE) { | |||||||
|     as.integer(x) %in% base::grep(pattern, levels(x), ignore.case = FALSE, fixed = fixed) |     as.integer(x) %in% base::grep(pattern, levels(x), ignore.case = FALSE, fixed = fixed) | ||||||
|   } else { |   } else { | ||||||
|     tryCatch(base::grepl(pattern, x, ignore.case = FALSE, fixed = fixed), |     tryCatch(base::grepl(pattern, x, ignore.case = FALSE, fixed = fixed), | ||||||
|              error = function(e) ifelse(grepl("Invalid regexp", e$message), |              error = function(e) { | ||||||
|  |                if (grepl("invalid reg(ular )?exp", e$message, ignore.case = TRUE)) { | ||||||
|                  # try with perl = TRUE: |                  # try with perl = TRUE: | ||||||
|                                         return(base::grepl(pattern = pattern, x = x, |                  return(base::grepl(pattern = pattern,  | ||||||
|  |                                     x = x, | ||||||
|                                     ignore.case = FALSE,  |                                     ignore.case = FALSE,  | ||||||
|                                     fixed = fixed, |                                     fixed = fixed, | ||||||
|                                                            perl = TRUE)), |                                     perl = TRUE)) | ||||||
|  |                } else { | ||||||
|                  # stop otherwise |                  # stop otherwise | ||||||
|                                         stop(e$message))) |                  stop(e$message) | ||||||
|  |                } | ||||||
|  |              }) | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										20
									
								
								R/rsi_calc.R
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								R/rsi_calc.R
									
									
									
									
									
								
							| @@ -40,6 +40,11 @@ rsi_calc <- function(..., | |||||||
|   data_vars <- dots2vars(...) |   data_vars <- dots2vars(...) | ||||||
|  |  | ||||||
|   dots_df <- switch(1, ...) |   dots_df <- switch(1, ...) | ||||||
|  |   if (is.data.frame(dots_df)) { | ||||||
|  |     # make sure to remove all other classes like tibbles, data.tables, etc | ||||||
|  |     dots_df <- as.data.frame(dots_df, stringsAsFactors = FALSE) | ||||||
|  |   } | ||||||
|  |    | ||||||
|   dots <- base::eval(base::substitute(base::alist(...))) |   dots <- base::eval(base::substitute(base::alist(...))) | ||||||
|   stop_if(length(dots) == 0, "no variables selected", call = -2) |   stop_if(length(dots) == 0, "no variables selected", call = -2) | ||||||
|  |  | ||||||
| @@ -50,6 +55,7 @@ rsi_calc <- function(..., | |||||||
|    |    | ||||||
|   if (is.data.frame(dots_df)) { |   if (is.data.frame(dots_df)) { | ||||||
|     # data.frame passed with other columns, like: example_isolates %>% proportion_S(AMC, GEN) |     # data.frame passed with other columns, like: example_isolates %>% proportion_S(AMC, GEN) | ||||||
|  |    | ||||||
|     dots <- as.character(dots) |     dots <- as.character(dots) | ||||||
|     # remove first element, it's the data.frame |     # remove first element, it's the data.frame | ||||||
|     if (length(dots) == 1) { |     if (length(dots) == 1) { | ||||||
| @@ -62,6 +68,10 @@ rsi_calc <- function(..., | |||||||
|       # and the old rsi function, which has "df" as name of the first parameter |       # and the old rsi function, which has "df" as name of the first parameter | ||||||
|       x <- dots_df |       x <- dots_df | ||||||
|     } else { |     } else { | ||||||
|  |       # get dots that are in column names already, and the ones that will be once evaluated using dots_df or global env | ||||||
|  |       # this is to support susceptibility(example_isolates, AMC, dplyr::all_of(some_vector_with_AB_names)) | ||||||
|  |       dots <- c(dots[dots %in% colnames(dots_df)], | ||||||
|  |                 eval(parse(text = dots[!dots %in% colnames(dots_df)]), envir = dots_df, enclos = globalenv())) | ||||||
|       dots_not_exist <- dots[!dots %in% colnames(dots_df)] |       dots_not_exist <- dots[!dots %in% colnames(dots_df)] | ||||||
|       stop_if(length(dots_not_exist) > 0, "column(s) not found: ", paste0("'", dots_not_exist, "'", collapse = ", "), call = -2) |       stop_if(length(dots_not_exist) > 0, "column(s) not found: ", paste0("'", dots_not_exist, "'", collapse = ", "), call = -2) | ||||||
|       x <- dots_df[, dots, drop = FALSE] |       x <- dots_df[, dots, drop = FALSE] | ||||||
| @@ -72,10 +82,10 @@ rsi_calc <- function(..., | |||||||
|   } else { |   } else { | ||||||
|     # multiple variables passed without pipe, like: proportion_S(example_isolates$AMC, example_isolates$GEN) |     # multiple variables passed without pipe, like: proportion_S(example_isolates$AMC, example_isolates$GEN) | ||||||
|     x <- NULL |     x <- NULL | ||||||
|     try(x <- as.data.frame(dots), silent = TRUE) |     try(x <- as.data.frame(dots, stringsAsFactors = FALSE), silent = TRUE) | ||||||
|     if (is.null(x)) { |     if (is.null(x)) { | ||||||
|       # support for example_isolates %>% group_by(hospital_id) %>% summarise(amox = susceptibility(GEN, AMX)) |       # support for example_isolates %>% group_by(hospital_id) %>% summarise(amox = susceptibility(GEN, AMX)) | ||||||
|       x <- as.data.frame(list(...)) |       x <- as.data.frame(list(...), stringsAsFactors = FALSE) | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|    |    | ||||||
| @@ -92,9 +102,9 @@ rsi_calc <- function(..., | |||||||
|     rsi_integrity_check <- character(0) |     rsi_integrity_check <- character(0) | ||||||
|     for (i in seq_len(ncol(x))) { |     for (i in seq_len(ncol(x))) { | ||||||
|       # check integrity of columns: force rsi class |       # check integrity of columns: force rsi class | ||||||
|       if (!is.rsi(x %>% pull(i))) { |       if (!is.rsi(x[, i, drop = TRUE])) { | ||||||
|         rsi_integrity_check <- c(rsi_integrity_check, x %>% pull(i) %>% as.character()) |         rsi_integrity_check <- c(rsi_integrity_check, as.character(x[, i, drop = TRUE])) | ||||||
|         x[, i] <- suppressWarnings(x %>% pull(i) %>% as.rsi()) # warning will be given later |         x[, i] <- suppressWarnings(as.rsi(x[, i, drop = TRUE])) # warning will be given later | ||||||
|         print_warning <- TRUE |         print_warning <- TRUE | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -81,7 +81,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="https://msberends.gitlab.io/AMR/index.html">AMR (for R)</a> |         <a class="navbar-link" href="https://msberends.gitlab.io/AMR/index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9022</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -81,7 +81,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="index.html">AMR (for R)</a> |         <a class="navbar-link" href="index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9022</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -81,7 +81,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9022</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -81,7 +81,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="index.html">AMR (for R)</a> |         <a class="navbar-link" href="index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9022</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -43,7 +43,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="index.html">AMR (for R)</a> |         <a class="navbar-link" href="index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9022</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -81,7 +81,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9022</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
| @@ -229,13 +229,13 @@ | |||||||
|       <small>Source: <a href='https://gitlab.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small> |       <small>Source: <a href='https://gitlab.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|     <div id="amr-1209022" class="section level1"> |     <div id="amr-1209023" class="section level1"> | ||||||
| <h1 class="page-header" data-toc-text="1.2.0.9022"> | <h1 class="page-header" data-toc-text="1.2.0.9023"> | ||||||
| <a href="#amr-1209022" class="anchor"></a>AMR 1.2.0.9022<small> Unreleased </small> | <a href="#amr-1209023" class="anchor"></a>AMR 1.2.0.9023<small> Unreleased </small> | ||||||
| </h1> | </h1> | ||||||
| <div id="last-updated-01-jul-2020" class="section level2"> | <div id="last-updated-02-jul-2020" class="section level2"> | ||||||
| <h2 class="hasAnchor"> | <h2 class="hasAnchor"> | ||||||
| <a href="#last-updated-01-jul-2020" class="anchor"></a><small>Last updated: 01-Jul-2020</small> | <a href="#last-updated-02-jul-2020" class="anchor"></a><small>Last updated: 02-Jul-2020</small> | ||||||
| </h2> | </h2> | ||||||
| <div id="new" class="section level3"> | <div id="new" class="section level3"> | ||||||
| <h3 class="hasAnchor"> | <h3 class="hasAnchor"> | ||||||
| @@ -262,10 +262,10 @@ | |||||||
| <h3 class="hasAnchor"> | <h3 class="hasAnchor"> | ||||||
| <a href="#changed" class="anchor"></a>Changed</h3> | <a href="#changed" class="anchor"></a>Changed</h3> | ||||||
| <ul> | <ul> | ||||||
| <li>Using unexisting columns in all <code>count_*()</code>, <code>proportion_*()</code>, <code><a href="../reference/proportion.html">susceptibility()</a></code> and <code><a href="../reference/proportion.html">resistance()</a></code> functions wil now return an error instead of dropping them silently</li> | <li>Using unexisting columns in all <code>count_*()</code>, <code>proportion_*()</code>, <code><a href="../reference/proportion.html">susceptibility()</a></code> and <code><a href="../reference/proportion.html">resistance()</a></code> functions wil now return an error instead of dropping them silently. Using variables for column names (as well as <code><a href="https://dplyr.tidyverse.org/reference/reexports.html">dplyr::all_of()</a></code>) now works again.</li> | ||||||
| <li>Improvements for <code><a href="../reference/as.ab.html">as.ab()</a></code>: | <li>Improvements for <code><a href="../reference/as.ab.html">as.ab()</a></code>: | ||||||
| <ul> | <ul> | ||||||
| <li>Dramatic improvement of the algorithm behind <code><a href="../reference/as.ab.html">as.ab()</a></code>, making many more input errors translatable like from digitalised health care records, using too few or too many vowels or consonants and many more</li> | <li>Dramatic improvement of the algorithm behind <code><a href="../reference/as.ab.html">as.ab()</a></code>, making many more input errors translatable, such as digitalised health care records, using too few or too many vowels or consonants and many more</li> | ||||||
| <li>Added progress bar</li> | <li>Added progress bar</li> | ||||||
| <li>Fixed a bug where <code><a href="../reference/as.ab.html">as.ab()</a></code> would return an error on invalid input values</li> | <li>Fixed a bug where <code><a href="../reference/as.ab.html">as.ab()</a></code> would return an error on invalid input values</li> | ||||||
| <li>The <code><a href="../reference/as.ab.html">as.ab()</a></code> function will now throw a note if more than 1 antimicrobial drug could be retrieved from a single input value.</li> | <li>The <code><a href="../reference/as.ab.html">as.ab()</a></code> function will now throw a note if more than 1 antimicrobial drug could be retrieved from a single input value.</li> | ||||||
| @@ -279,6 +279,7 @@ | |||||||
| <li>Fixed a bug in <code><a href="../reference/bug_drug_combinations.html">bug_drug_combinations()</a></code> for when only one antibiotic was in the input data</li> | <li>Fixed a bug in <code><a href="../reference/bug_drug_combinations.html">bug_drug_combinations()</a></code> for when only one antibiotic was in the input data</li> | ||||||
| <li>Changed the summary for class <code><mo></code>, to highlight the %SI vs. %R</li> | <li>Changed the summary for class <code><mo></code>, to highlight the %SI vs. %R</li> | ||||||
| <li>Improved error handling, giving more useful info when functions return an error</li> | <li>Improved error handling, giving more useful info when functions return an error</li> | ||||||
|  | <li>Any progress bar will now only show in interactive mode (i.e. not in R Markdown)</li> | ||||||
| </ul> | </ul> | ||||||
| </div> | </div> | ||||||
| </div> | </div> | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ articles: | |||||||
|   WHONET: WHONET.html |   WHONET: WHONET.html | ||||||
|   benchmarks: benchmarks.html |   benchmarks: benchmarks.html | ||||||
|   resistance_predict: resistance_predict.html |   resistance_predict: resistance_predict.html | ||||||
| last_built: 2020-07-01T14:20Z | last_built: 2020-07-02T19:12Z | ||||||
| urls: | urls: | ||||||
|   reference: https://msberends.gitlab.io/AMR/reference |   reference: https://msberends.gitlab.io/AMR/reference | ||||||
|   article: https://msberends.gitlab.io/AMR/articles |   article: https://msberends.gitlab.io/AMR/articles | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9019</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9019</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
| @@ -240,6 +240,7 @@ | |||||||
|   <span class='kw'>type</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"drug"</span>, <span class='st'>"dose"</span>, <span class='st'>"administration"</span>), |   <span class='kw'>type</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"drug"</span>, <span class='st'>"dose"</span>, <span class='st'>"administration"</span>), | ||||||
|   <span class='kw'>collapse</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, |   <span class='kw'>collapse</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, | ||||||
|   <span class='kw'>translate_ab</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, |   <span class='kw'>translate_ab</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, | ||||||
|  |   <span class='kw'>thorough_search</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, | ||||||
|   <span class='no'>...</span> |   <span class='no'>...</span> | ||||||
| )</pre> | )</pre> | ||||||
|  |  | ||||||
| @@ -262,6 +263,10 @@ | |||||||
|       <th>translate_ab</th> |       <th>translate_ab</th> | ||||||
|       <td><p>if <code>type = "drug"</code>: a column name of the <a href='antibiotics.html'>antibiotics</a> data set to translate the antibiotic abbreviations to, using <code><a href='ab_property.html'>ab_property()</a></code>. Defaults to <code>FALSE</code>. Using <code>TRUE</code> is equal to using "name".</p></td> |       <td><p>if <code>type = "drug"</code>: a column name of the <a href='antibiotics.html'>antibiotics</a> data set to translate the antibiotic abbreviations to, using <code><a href='ab_property.html'>ab_property()</a></code>. Defaults to <code>FALSE</code>. Using <code>TRUE</code> is equal to using "name".</p></td> | ||||||
|     </tr> |     </tr> | ||||||
|  |     <tr> | ||||||
|  |       <th>thorough_search</th> | ||||||
|  |       <td><p>logical to indicate whether the input must be extensively searched for misspelling and other faulty input values. Setting this to <code>TRUE</code> will take considerably more time than when using <code>FALSE</code>. At default, it will turn <code>TRUE</code> when all input elements contain a maximum of three words.</p></td> | ||||||
|  |     </tr> | ||||||
|     <tr> |     <tr> | ||||||
|       <th>...</th> |       <th>...</th> | ||||||
|       <td><p>parameters passed on to <code><a href='as.ab.html'>as.ab()</a></code></p></td> |       <td><p>parameters passed on to <code><a href='as.ab.html'>as.ab()</a></code></p></td> | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9022</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -83,7 +83,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9019</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9019</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9019</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9019</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -81,7 +81,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9022</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -84,7 +84,7 @@ This page contains a section for every lifecycle (with text borrowed from the af | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9019</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9019</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9019</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ | |||||||
|       </button> |       </button> | ||||||
|       <span class="navbar-brand"> |       <span class="navbar-brand"> | ||||||
|         <a class="navbar-link" href="../index.html">AMR (for R)</a> |         <a class="navbar-link" href="../index.html">AMR (for R)</a> | ||||||
|         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9019</span> |         <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9023</span> | ||||||
|       </span> |       </span> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ ab_from_text( | |||||||
|   type = c("drug", "dose", "administration"), |   type = c("drug", "dose", "administration"), | ||||||
|   collapse = NULL, |   collapse = NULL, | ||||||
|   translate_ab = FALSE, |   translate_ab = FALSE, | ||||||
|  |   thorough_search = NULL, | ||||||
|   ... |   ... | ||||||
| ) | ) | ||||||
| } | } | ||||||
| @@ -21,6 +22,8 @@ ab_from_text( | |||||||
|  |  | ||||||
| \item{translate_ab}{if \code{type = "drug"}: a column name of the \link{antibiotics} data set to translate the antibiotic abbreviations to, using \code{\link[=ab_property]{ab_property()}}. Defaults to \code{FALSE}. Using \code{TRUE} is equal to using "name".} | \item{translate_ab}{if \code{type = "drug"}: a column name of the \link{antibiotics} data set to translate the antibiotic abbreviations to, using \code{\link[=ab_property]{ab_property()}}. Defaults to \code{FALSE}. Using \code{TRUE} is equal to using "name".} | ||||||
|  |  | ||||||
|  | \item{thorough_search}{logical to indicate whether the input must be extensively searched for misspelling and other faulty input values. Setting this to \code{TRUE} will take considerably more time than when using \code{FALSE}. At default, it will turn \code{TRUE} when all input elements contain a maximum of three words.} | ||||||
|  |  | ||||||
| \item{...}{parameters passed on to \code{\link[=as.ab]{as.ab()}}} | \item{...}{parameters passed on to \code{\link[=as.ab]{as.ab()}}} | ||||||
| } | } | ||||||
| \value{ | \value{ | ||||||
|   | |||||||
| @@ -23,8 +23,14 @@ context("ab_from_text.R") | |||||||
|  |  | ||||||
| test_that("ab_from_text works", { | test_that("ab_from_text works", { | ||||||
|    |    | ||||||
|  |   skip_on_cran() | ||||||
|  |    | ||||||
|   expect_identical(ab_from_text("28/03/2020 regular amoxicilliin 500mg po tds")[[1]], |   expect_identical(ab_from_text("28/03/2020 regular amoxicilliin 500mg po tds")[[1]], | ||||||
|                    as.ab("Amoxicillin")) |                    as.ab("Amoxicillin")) | ||||||
|  |   expect_identical(ab_from_text("28/03/2020 regular amoxicilliin 500mg po tds", thorough_search = TRUE)[[1]], | ||||||
|  |                    as.ab("Amoxicillin")) | ||||||
|  |   expect_identical(ab_from_text("28/03/2020 regular amoxicilliin 500mg po tds", thorough_search = FALSE)[[1]], | ||||||
|  |                    as.ab("Amoxicillin")) | ||||||
|   expect_identical(ab_from_text("28/03/2020 regular amoxicilliin 500mg po tds", translate_ab = TRUE)[[1]], |   expect_identical(ab_from_text("28/03/2020 regular amoxicilliin 500mg po tds", translate_ab = TRUE)[[1]], | ||||||
|                    "Amoxicillin") |                    "Amoxicillin") | ||||||
|   expect_identical(ab_from_text("administered amoxi/clav and cipro", collapse = ", ")[[1]], |   expect_identical(ab_from_text("administered amoxi/clav and cipro", collapse = ", ")[[1]], | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user