mirror of
				https://github.com/msberends/AMR.git
				synced 2025-11-04 07:54:07 +01:00 
			
		
		
		
	(v0.7.1.9072) key_antibiotics() for foreign systems
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
				
			|||||||
Package: AMR
 | 
					Package: AMR
 | 
				
			||||||
Version: 0.7.1.9071
 | 
					Version: 0.7.1.9072
 | 
				
			||||||
Date: 2019-09-03
 | 
					Date: 2019-09-12
 | 
				
			||||||
Title: Antimicrobial Resistance Analysis
 | 
					Title: Antimicrobial Resistance Analysis
 | 
				
			||||||
Authors@R: c(
 | 
					Authors@R: c(
 | 
				
			||||||
    person(role = c("aut", "cre"), 
 | 
					    person(role = c("aut", "cre"), 
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								NEWS.md
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								NEWS.md
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
				
			|||||||
# AMR 0.7.1.9071
 | 
					# AMR 0.7.1.9072
 | 
				
			||||||
<small>Last updated: 03-Sep-2019</small>
 | 
					<small>Last updated: 12-Sep-2019</small>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Breaking
 | 
					### Breaking
 | 
				
			||||||
* Determination of first isolates now **excludes** all 'unknown' microorganisms at default, i.e. microbial code `"UNKNOWN"`. They can be included with the new parameter `include_unknown`:
 | 
					* Determination of first isolates now **excludes** all 'unknown' microorganisms at default, i.e. microbial code `"UNKNOWN"`. They can be included with the new parameter `include_unknown`:
 | 
				
			||||||
@@ -99,6 +99,9 @@
 | 
				
			|||||||
* Function `availability()` now uses `portion_R()` instead of `portion_IR()`, to comply with EUCAST insights
 | 
					* Function `availability()` now uses `portion_R()` instead of `portion_IR()`, to comply with EUCAST insights
 | 
				
			||||||
* Functions `age()` and `age_groups()` now have a `na.rm` parameter to remove empty values
 | 
					* Functions `age()` and `age_groups()` now have a `na.rm` parameter to remove empty values
 | 
				
			||||||
* Renamed function `p.symbol()` to `p_symbol()` (the former is now deprecated and will be removed in a future version)
 | 
					* Renamed function `p.symbol()` to `p_symbol()` (the former is now deprecated and will be removed in a future version)
 | 
				
			||||||
 | 
					* Using negative values for `x` in `age_groups()` will now introduce `NA`s and not return an error anymore
 | 
				
			||||||
 | 
					* Fix for determining the system's language
 | 
				
			||||||
 | 
					* Fix for `key_antibiotics()` on foreign systems
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### Other
 | 
					#### Other
 | 
				
			||||||
* Added Prof Dr Casper Albers as doctoral advisor and Dr Bart Meijer, Dr Dennis Souverein and Annick Lenglet as contributors
 | 
					* Added Prof Dr Casper Albers as doctoral advisor and Dr Bart Meijer, Dr Dennis Souverein and Annick Lenglet as contributors
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								R/age.R
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								R/age.R
									
									
									
									
									
								
							@@ -145,6 +145,10 @@ age_groups <- function(x, split_at = c(12, 25, 55, 75), na.rm = FALSE) {
 | 
				
			|||||||
  if (!is.numeric(x)) {
 | 
					  if (!is.numeric(x)) {
 | 
				
			||||||
    stop("`x` and must be numeric, not a ", paste0(class(x), collapse = "/"), ".")
 | 
					    stop("`x` and must be numeric, not a ", paste0(class(x), collapse = "/"), ".")
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  if (any(x < 0, na.rm = TRUE)) {
 | 
				
			||||||
 | 
					    x[x < 0] <- NA
 | 
				
			||||||
 | 
					    warning("NAs introduced for ages below 0.")
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  if (is.character(split_at)) {
 | 
					  if (is.character(split_at)) {
 | 
				
			||||||
    split_at <- split_at[1L]
 | 
					    split_at <- split_at[1L]
 | 
				
			||||||
    if (split_at %like% "^(child|kid|junior)") {
 | 
					    if (split_at %like% "^(child|kid|junior)") {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -81,7 +81,7 @@ atc_online_property <- function(atc_code,
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!all(atc_code %in% AMR::antibiotics)) {
 | 
					  if (!all(atc_code %in% AMR::antibiotics)) {
 | 
				
			||||||
    atc_code <- as.character(as.atc(atc_code))
 | 
					    atc_code <- as.character(ab_atc(atc_code))
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!curl::has_internet()) {
 | 
					  if (!curl::has_internet()) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -184,25 +184,28 @@ key_antibiotics <- function(x,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  # join to microorganisms data set
 | 
					  # join to microorganisms data set
 | 
				
			||||||
  x <- x %>%
 | 
					  x <- x %>%
 | 
				
			||||||
 | 
					    as.data.frame(stringsAsFactors = FALSE) %>% 
 | 
				
			||||||
    mutate_at(vars(col_mo), as.mo) %>%
 | 
					    mutate_at(vars(col_mo), as.mo) %>%
 | 
				
			||||||
    left_join_microorganisms(by = col_mo) %>%
 | 
					    left_join_microorganisms(by = col_mo) %>%
 | 
				
			||||||
    mutate(key_ab = NA_character_,
 | 
					    mutate(key_ab = NA_character_,
 | 
				
			||||||
           gramstain = mo_gramstain(pull(., col_mo)))
 | 
					           gramstain = mo_gramstain(pull(., col_mo), language = NULL))
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  # Gram +
 | 
					  # Gram +
 | 
				
			||||||
  x <- x %>% mutate(key_ab =
 | 
					  x <- x %>% mutate(key_ab =
 | 
				
			||||||
                      if_else(gramstain == "Gram-positive",
 | 
					                      if_else(gramstain == "Gram-positive",
 | 
				
			||||||
                              apply(X = x[, gram_positive],
 | 
					                              tryCatch(apply(X = x[, gram_positive],
 | 
				
			||||||
                                             MARGIN = 1,
 | 
					                                             MARGIN = 1,
 | 
				
			||||||
                                             FUN = function(x) paste(x, collapse = "")),
 | 
					                                             FUN = function(x) paste(x, collapse = "")),
 | 
				
			||||||
 | 
					                                       error = function(e) paste0(rep(".", 12), collapse = "")),
 | 
				
			||||||
                              key_ab))
 | 
					                              key_ab))
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  # Gram -
 | 
					  # Gram -
 | 
				
			||||||
  x <- x %>% mutate(key_ab =
 | 
					  x <- x %>% mutate(key_ab =
 | 
				
			||||||
                      if_else(gramstain == "Gram-negative",
 | 
					                      if_else(gramstain == "Gram-negative",
 | 
				
			||||||
                              apply(X = x[, gram_negative],
 | 
					                              tryCatch(apply(X = x[, gram_negative],
 | 
				
			||||||
                                             MARGIN = 1,
 | 
					                                             MARGIN = 1,
 | 
				
			||||||
                                             FUN = function(x) paste(x, collapse = "")),
 | 
					                                             FUN = function(x) paste(x, collapse = "")),
 | 
				
			||||||
 | 
					                                       error = function(e) paste0(rep(".", 12), collapse = "")),
 | 
				
			||||||
                              key_ab))
 | 
					                              key_ab))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # format
 | 
					  # format
 | 
				
			||||||
@@ -212,6 +215,10 @@ key_antibiotics <- function(x,
 | 
				
			|||||||
    gsub('[^SIR]', '.', ., ignore.case = TRUE) %>%
 | 
					    gsub('[^SIR]', '.', ., ignore.case = TRUE) %>%
 | 
				
			||||||
    toupper()
 | 
					    toupper()
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					  if (n_distinct(key_abs) == 1) {
 | 
				
			||||||
 | 
					    warning("No distinct key antibiotics determined.", call. = FALSE)
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  key_abs
 | 
					  key_abs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								R/like.R
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								R/like.R
									
									
									
									
									
								
							@@ -56,8 +56,16 @@
 | 
				
			|||||||
like <- function(x, pattern) {
 | 
					like <- function(x, pattern) {
 | 
				
			||||||
  if (length(pattern) > 1) {
 | 
					  if (length(pattern) > 1) {
 | 
				
			||||||
    if (length(x) != length(pattern)) {
 | 
					    if (length(x) != length(pattern)) {
 | 
				
			||||||
      pattern <- pattern[1]
 | 
					      if (length(x) == 1) {
 | 
				
			||||||
      warning('only the first element of argument `pattern` used for `%like%`', call. = TRUE)
 | 
					        x <- rep(x, length(pattern))
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      # return TRUE for every 'x' that matches any 'pattern', FALSE otherwise
 | 
				
			||||||
 | 
					      res <- sapply(pattern, function(pttrn) x %like% pttrn)
 | 
				
			||||||
 | 
					      res2 <- as.logical(rowSums(res))
 | 
				
			||||||
 | 
					      # get only first item of every hit in pattern
 | 
				
			||||||
 | 
					      res2[duplicated(res)] <- FALSE
 | 
				
			||||||
 | 
					      res2[rowSums(res) == 0] <- NA
 | 
				
			||||||
 | 
					      return(res2)
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      # x and pattern are of same length, so items with each other
 | 
					      # x and pattern are of same length, so items with each other
 | 
				
			||||||
      res <- vector(length = length(pattern))
 | 
					      res <- vector(length = length(pattern))
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										55
									
								
								R/misc.R
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								R/misc.R
									
									
									
									
									
								
							@@ -123,61 +123,6 @@ stopifnot_installed_package <- function(package) {
 | 
				
			|||||||
  return(invisible())
 | 
					  return(invisible())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# translate strings based on inst/translations.tsv
 | 
					 | 
				
			||||||
#' @importFrom dplyr %>% filter
 | 
					 | 
				
			||||||
translate_AMR <- function(from, language = get_locale(), only_unknown = FALSE) {
 | 
					 | 
				
			||||||
  # if (getOption("AMR_locale", "en") != language) {
 | 
					 | 
				
			||||||
  #   language <- getOption("AMR_locale", "en")
 | 
					 | 
				
			||||||
  # }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (is.null(language)) {
 | 
					 | 
				
			||||||
    return(from)
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  if (language %in% c("en", "")) {
 | 
					 | 
				
			||||||
    return(from)
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  df_trans <- translations_file # internal data file
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (!language %in% df_trans$lang) {
 | 
					 | 
				
			||||||
    stop("Unsupported language: '", language, "' - use one of: ",
 | 
					 | 
				
			||||||
         paste0("'", sort(unique(df_trans$lang)), "'", collapse = ", "),
 | 
					 | 
				
			||||||
         call. = FALSE)
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  df_trans <- df_trans %>% filter(lang == language)
 | 
					 | 
				
			||||||
  if (only_unknown == TRUE) {
 | 
					 | 
				
			||||||
    df_trans <- df_trans %>% filter(pattern %like% "unknown")
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  # default case sensitive if value if 'ignore.case' is missing:
 | 
					 | 
				
			||||||
  df_trans$ignore.case[is.na(df_trans$ignore.case)] <- FALSE
 | 
					 | 
				
			||||||
  # default not using regular expressions (fixed = TRUE) if 'fixed' is missing:
 | 
					 | 
				
			||||||
  df_trans$fixed[is.na(df_trans$fixed)] <- TRUE
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  # check if text to look for is in one of the patterns
 | 
					 | 
				
			||||||
  any_form_in_patterns <- tryCatch(any(from %like% paste0("(", paste(df_trans$pattern, collapse = "|"), ")")),
 | 
					 | 
				
			||||||
                                   error = function(e) {
 | 
					 | 
				
			||||||
                                     warning("Translation not possible. Please open an issue on GitLab (https://gitlab.com/msberends/AMR/issues) or GitHub (https://github.com/msberends/AMR/issues).", call. = FALSE)
 | 
					 | 
				
			||||||
                                     return(FALSE)
 | 
					 | 
				
			||||||
                                   })
 | 
					 | 
				
			||||||
  if (NROW(df_trans) == 0 | !any_form_in_patterns) {
 | 
					 | 
				
			||||||
    return(from)
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for (i in 1:nrow(df_trans)) {
 | 
					 | 
				
			||||||
    from <- gsub(x = from,
 | 
					 | 
				
			||||||
                 pattern = df_trans$pattern[i],
 | 
					 | 
				
			||||||
                 replacement = df_trans$replacement[i],
 | 
					 | 
				
			||||||
                 fixed = df_trans$fixed[i],
 | 
					 | 
				
			||||||
                 ignore.case = df_trans$ignore.case[i])
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  # force UTF-8 for diacritics
 | 
					 | 
				
			||||||
  base::enc2utf8(from)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
"%or%" <- function(x, y) {
 | 
					"%or%" <- function(x, y) {
 | 
				
			||||||
  if (is.null(x) | is.null(y)) {
 | 
					  if (is.null(x) | is.null(y)) {
 | 
				
			||||||
    if (is.null(x)) {
 | 
					    if (is.null(x)) {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										48
									
								
								R/mo.R
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								R/mo.R
									
									
									
									
									
								
							@@ -432,13 +432,13 @@ exec_as.mo <- function(x,
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    x <- y
 | 
					    x <- y
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  } else if (all(x %in% read_mo_history(uncertainty_level,
 | 
					    # } else if (all(x %in% read_mo_history(uncertainty_level,
 | 
				
			||||||
                                        force = force_mo_history)$x)) {
 | 
					    #                                       force = force_mo_history)$x)) {
 | 
				
			||||||
    # previously found code
 | 
					    #   # previously found code
 | 
				
			||||||
    x <- microorganismsDT[data.table(mo = get_mo_history(x,
 | 
					    #   x <- microorganismsDT[data.table(mo = get_mo_history(x,
 | 
				
			||||||
                                                         uncertainty_level,
 | 
					    #                                                        uncertainty_level,
 | 
				
			||||||
                                                         force = force_mo_history)),
 | 
					    #                                                        force = force_mo_history)),
 | 
				
			||||||
                          on = "mo", ..property][[1]]
 | 
					    #                         on = "mo", ..property][[1]]
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  } else if (all(tolower(x) %in% microorganismsDT$fullname_lower)) {
 | 
					  } else if (all(tolower(x) %in% microorganismsDT$fullname_lower)) {
 | 
				
			||||||
    # we need special treatment for very prevalent full names, they are likely!
 | 
					    # we need special treatment for very prevalent full names, they are likely!
 | 
				
			||||||
@@ -561,17 +561,17 @@ exec_as.mo <- function(x,
 | 
				
			|||||||
      
 | 
					      
 | 
				
			||||||
      progress$tick()$print()
 | 
					      progress$tick()$print()
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      if (initial_search == TRUE) {
 | 
					      # if (initial_search == TRUE) {
 | 
				
			||||||
        found <- microorganismsDT[mo == get_mo_history(x_backup[i],
 | 
					      #   found <- microorganismsDT[mo == get_mo_history(x_backup[i],
 | 
				
			||||||
                                                       uncertainty_level,
 | 
					      #                                                  uncertainty_level,
 | 
				
			||||||
                                                       force = force_mo_history),
 | 
					      #                                                  force = force_mo_history),
 | 
				
			||||||
                                  ..property][[1]]
 | 
					      #                             ..property][[1]]
 | 
				
			||||||
        # previously found result
 | 
					      #   # previously found result
 | 
				
			||||||
        if (length(found) > 0) {
 | 
					      #   if (length(found) > 0) {
 | 
				
			||||||
          x[i] <- found[1L]
 | 
					      #     x[i] <- found[1L]
 | 
				
			||||||
          next
 | 
					      #     next
 | 
				
			||||||
        }
 | 
					      #   }
 | 
				
			||||||
      }
 | 
					      # }
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      found <- microorganismsDT[mo == toupper(x_backup[i]), ..property][[1]]
 | 
					      found <- microorganismsDT[mo == toupper(x_backup[i]), ..property][[1]]
 | 
				
			||||||
      # is a valid MO code
 | 
					      # is a valid MO code
 | 
				
			||||||
@@ -826,6 +826,7 @@ exec_as.mo <- function(x,
 | 
				
			|||||||
            if (initial_search == TRUE) {
 | 
					            if (initial_search == TRUE) {
 | 
				
			||||||
              set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history)
 | 
					              set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history)
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            next
 | 
				
			||||||
          } else if (grepl("[sS]almonella [A-Z][a-z]+ ?.*", x_backup_without_spp[i], ignore.case = FALSE)) {
 | 
					          } else if (grepl("[sS]almonella [A-Z][a-z]+ ?.*", x_backup_without_spp[i], ignore.case = FALSE)) {
 | 
				
			||||||
            # Salmonella with capital letter species like "Salmonella Goettingen" - they're all S. enterica
 | 
					            # Salmonella with capital letter species like "Salmonella Goettingen" - they're all S. enterica
 | 
				
			||||||
            x[i] <- microorganismsDT[mo == 'B_SLMNL_ENT', ..property][[1]][1L]
 | 
					            x[i] <- microorganismsDT[mo == 'B_SLMNL_ENT', ..property][[1]][1L]
 | 
				
			||||||
@@ -833,12 +834,12 @@ exec_as.mo <- function(x,
 | 
				
			|||||||
              set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history)
 | 
					              set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history)
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            uncertainties <- rbind(uncertainties,
 | 
					            uncertainties <- rbind(uncertainties,
 | 
				
			||||||
                                   data.frame(uncertainty_level = 1,
 | 
					                                   format_uncertainty_as_df(uncertainty_level = 1,
 | 
				
			||||||
                                                            input = x_backup_without_spp[i],
 | 
					                                                            input = x_backup_without_spp[i],
 | 
				
			||||||
                                                            result_mo = "B_SLMNL_ENT"))
 | 
					                                                            result_mo = "B_SLMNL_ENT"))
 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
            next
 | 
					            next
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        # trivial names known to the field:
 | 
					        # trivial names known to the field:
 | 
				
			||||||
        if ("meningococcus" %like% x_trimmed[i]) {
 | 
					        if ("meningococcus" %like% x_trimmed[i]) {
 | 
				
			||||||
@@ -1850,8 +1851,11 @@ mo_renamed <- function() {
 | 
				
			|||||||
#' @export
 | 
					#' @export
 | 
				
			||||||
#' @noRd
 | 
					#' @noRd
 | 
				
			||||||
print.mo_renamed <- function(x, ...) {
 | 
					print.mo_renamed <- function(x, ...) {
 | 
				
			||||||
  items <- getOption("mo_renamed")
 | 
					  items <- x #getOption("mo_renamed")
 | 
				
			||||||
  base::message(blue(paste("NOTE:", names(items), "was renamed", items, collapse = "\n"), collapse = "\n"))
 | 
					  old <- names(x)
 | 
				
			||||||
 | 
					  new <- x
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  cat(blue(paste("NOTE:", italic(names(items)), "was renamed", italic(items), collapse = "\n"), collapse = "\n"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
nr2char <- function(x) {
 | 
					nr2char <- function(x) {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										
											BIN
										
									
								
								R/sysdata.rda
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								R/sysdata.rda
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -64,7 +64,7 @@
 | 
				
			|||||||
#' mo_name("CoNS", language = "pt")
 | 
					#' mo_name("CoNS", language = "pt")
 | 
				
			||||||
#' #> "Staphylococcus coagulase negativo (CoNS)"
 | 
					#' #> "Staphylococcus coagulase negativo (CoNS)"
 | 
				
			||||||
get_locale <- function() {
 | 
					get_locale <- function() {
 | 
				
			||||||
  if (getOption("AMR_locale", "en") != "en") {
 | 
					  if (!is.null(getOption("AMR_locale", default = NULL))) {
 | 
				
			||||||
    return(getOption("AMR_locale"))
 | 
					    return(getOption("AMR_locale"))
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -73,6 +73,7 @@ get_locale <- function() {
 | 
				
			|||||||
  # Check the locale settings for a start with one of these languages:
 | 
					  # Check the locale settings for a start with one of these languages:
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  # grepl() with ignore.case = FALSE is faster than %like%
 | 
					  # grepl() with ignore.case = FALSE is faster than %like%
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
  if (grepl("^(English|en_|EN_)", lang, ignore.case = FALSE)) {
 | 
					  if (grepl("^(English|en_|EN_)", lang, ignore.case = FALSE)) {
 | 
				
			||||||
    # as first option to optimise speed
 | 
					    # as first option to optimise speed
 | 
				
			||||||
    "en"
 | 
					    "en"
 | 
				
			||||||
@@ -93,3 +94,55 @@ get_locale <- function() {
 | 
				
			|||||||
    "en"
 | 
					    "en"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# translate strings based on inst/translations.tsv
 | 
				
			||||||
 | 
					#' @importFrom dplyr %>% filter
 | 
				
			||||||
 | 
					translate_AMR <- function(from, language = get_locale(), only_unknown = FALSE) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (is.null(language)) {
 | 
				
			||||||
 | 
					    return(from)
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if (language %in% c("en", "", NA)) {
 | 
				
			||||||
 | 
					    return(from)
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  df_trans <- translations_file # internal data file
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  if (!language %in% df_trans$lang) {
 | 
				
			||||||
 | 
					    stop("Unsupported language: '", language, "' - use one of: ",
 | 
				
			||||||
 | 
					         paste0("'", sort(unique(df_trans$lang)), "'", collapse = ", "),
 | 
				
			||||||
 | 
					         call. = FALSE)
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  df_trans <- df_trans %>% filter(lang == language)
 | 
				
			||||||
 | 
					  if (only_unknown == TRUE) {
 | 
				
			||||||
 | 
					    df_trans <- df_trans %>% filter(pattern %like% "unknown")
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  # default case sensitive if value if 'ignore.case' is missing:
 | 
				
			||||||
 | 
					  df_trans$ignore.case[is.na(df_trans$ignore.case)] <- FALSE
 | 
				
			||||||
 | 
					  # default not using regular expressions (fixed = TRUE) if 'fixed' is missing:
 | 
				
			||||||
 | 
					  df_trans$fixed[is.na(df_trans$fixed)] <- TRUE
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  # check if text to look for is in one of the patterns
 | 
				
			||||||
 | 
					  any_form_in_patterns <- tryCatch(any(from %like% paste0("(", paste(df_trans$pattern, collapse = "|"), ")")),
 | 
				
			||||||
 | 
					                                   error = function(e) {
 | 
				
			||||||
 | 
					                                     warning("Translation not possible. Please open an issue on GitLab (https://gitlab.com/msberends/AMR/issues) or GitHub (https://github.com/msberends/AMR/issues).", call. = FALSE)
 | 
				
			||||||
 | 
					                                     return(FALSE)
 | 
				
			||||||
 | 
					                                   })
 | 
				
			||||||
 | 
					  if (NROW(df_trans) == 0 | !any_form_in_patterns) {
 | 
				
			||||||
 | 
					    return(from)
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  for (i in 1:nrow(df_trans)) {
 | 
				
			||||||
 | 
					    from <- gsub(x = from,
 | 
				
			||||||
 | 
					                 pattern = df_trans$pattern[i],
 | 
				
			||||||
 | 
					                 replacement = df_trans$replacement[i],
 | 
				
			||||||
 | 
					                 fixed = df_trans$fixed[i],
 | 
				
			||||||
 | 
					                 ignore.case = df_trans$ignore.case[i])
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  # force UTF-8 for diacritics
 | 
				
			||||||
 | 
					  base::enc2utf8(from)
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,9 +1,9 @@
 | 
				
			|||||||
# ---------------------------------------------------------------------------------------------------
 | 
					# ---------------------------------------------------------------------------------------------------
 | 
				
			||||||
# For editing this EUCAST reference file, these values can all be used for target antibiotics:
 | 
					# For editing this EUCAST reference file, these values can all be used for target antibiotics:
 | 
				
			||||||
# all_betalactams, aminoglycosides, carbapenems, cephalosporins, cephalosporins_without_CAZ, fluoroquinolones, 
 | 
					# 'all_betalactams', 'aminoglycosides', 'aminopenicillins', 'carbapenems', 'cephalosporins', 'cephalosporins_without_CAZ',
 | 
				
			||||||
# glycopeptides, macrolides, minopenicillins, polymyxins, streptogramins, tetracyclines, ureidopenicillins
 | 
					# 'fluoroquinolones', 'glycopeptides', 'macrolides', 'polymyxins', 'streptogramins', 'tetracyclines', 'ureidopenicillins'
 | 
				
			||||||
# and all separate EARS-Net letter codes like AMC. They can be separated by comma: 'AMC, fluoroquinolones'.
 | 
					# and all separate EARS-Net letter codes like 'AMC'. They can be separated by comma: 'AMC, fluoroquinolones'.
 | 
				
			||||||
# The if_mo_property column can be any column name from the AMR::microorganisms data set, or "genus_species" or "gramstain".
 | 
					# The 'if_mo_property' column can be any column name from the AMR::microorganisms data set, or "genus_species" or "gramstain".
 | 
				
			||||||
# The like.is.one_of column must contain one of: like, is, one_of ('like' will read the first column as regular expression)
 | 
					# The like.is.one_of column must contain one of: like, is, one_of ('like' will read the first column as regular expression)
 | 
				
			||||||
# The EUCAST guideline contains references to the 'Burkholderia cepacia complex'. All species in this group can be found in: LiPuma J, Curr Opin Pulm Med. 2005 Nov;11(6):528-33. (PMID 16217180).
 | 
					# The EUCAST guideline contains references to the 'Burkholderia cepacia complex'. All species in this group can be found in: LiPuma J, Curr Opin Pulm Med. 2005 Nov;11(6):528-33. (PMID 16217180).
 | 
				
			||||||
# >>>>> IF YOU WANT TO IMPORT THIS FILE INTO YOUR OWN SOFTWARE, HAVE THE FIRST 10 LINES SKIPPED <<<<<
 | 
					# >>>>> IF YOU WANT TO IMPORT THIS FILE INTO YOUR OWN SOFTWARE, HAVE THE FIRST 10 LINES SKIPPED <<<<<
 | 
				
			||||||
 
 | 
				
			|||||||
| 
		
		
			 Can't render this file because it contains an unexpected character in line 6 and column 94. 
		
	 | 
@@ -354,7 +354,7 @@ nl	Ticarcillin/beta-lactamase inhibitor	Ticarcilline/enzymremmer
 | 
				
			|||||||
nl	Ticarcillin/clavulanic acid	Ticarcilline/clavulaanzuur
 | 
					nl	Ticarcillin/clavulanic acid	Ticarcilline/clavulaanzuur
 | 
				
			||||||
nl	Tinidazole	Tinidazol
 | 
					nl	Tinidazole	Tinidazol
 | 
				
			||||||
nl	Tobramycin	Tobramycine
 | 
					nl	Tobramycin	Tobramycine
 | 
				
			||||||
nl	Trimethoprim/sulfamethoxazole	Trimethoprim/sulfamethoxazol
 | 
					nl	Trimethoprim/sulfamethoxazole	Cotrimoxazol
 | 
				
			||||||
nl	Troleandomycin	Troleandomycine
 | 
					nl	Troleandomycin	Troleandomycine
 | 
				
			||||||
nl	Trovafloxacin	Trovafloxacine
 | 
					nl	Trovafloxacin	Trovafloxacine
 | 
				
			||||||
nl	Vancomycin	Vancomycine
 | 
					nl	Vancomycin	Vancomycine
 | 
				
			||||||
 
 | 
				
			|||||||
| 
		
		
			 Can't render this file because it has a wrong number of fields in line 159. 
		
	 | 
@@ -78,7 +78,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">0.7.1.9071</span>
 | 
					        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9072</span>
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,7 +78,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">0.7.1.9071</span>
 | 
					        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9072</span>
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,7 +78,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">0.7.1.9071</span>
 | 
					        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9072</span>
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,7 +42,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">0.7.1.9071</span>
 | 
					        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9072</span>
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,7 +78,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">0.7.1.9071</span>
 | 
					        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9072</span>
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -225,11 +225,11 @@
 | 
				
			|||||||
      
 | 
					      
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <div id="amr-0-7-1-9071" class="section level1">
 | 
					    <div id="amr-0-7-1-9072" class="section level1">
 | 
				
			||||||
<h1 class="page-header">
 | 
					<h1 class="page-header">
 | 
				
			||||||
<a href="#amr-0-7-1-9071" class="anchor"></a>AMR 0.7.1.9071<small> Unreleased </small>
 | 
					<a href="#amr-0-7-1-9072" class="anchor"></a>AMR 0.7.1.9072<small> Unreleased </small>
 | 
				
			||||||
</h1>
 | 
					</h1>
 | 
				
			||||||
<p><small>Last updated: 03-Sep-2019</small></p>
 | 
					<p><small>Last updated: 12-Sep-2019</small></p>
 | 
				
			||||||
<div id="breaking" class="section level3">
 | 
					<div id="breaking" class="section level3">
 | 
				
			||||||
<h3 class="hasAnchor">
 | 
					<h3 class="hasAnchor">
 | 
				
			||||||
<a href="#breaking" class="anchor"></a>Breaking</h3>
 | 
					<a href="#breaking" class="anchor"></a>Breaking</h3>
 | 
				
			||||||
@@ -342,6 +342,9 @@ Since this is a major change, usage of the old <code>also_single_tested</code> w
 | 
				
			|||||||
<li>Function <code><a href="../reference/availability.html">availability()</a></code> now uses <code><a href="../reference/portion.html">portion_R()</a></code> instead of <code><a href="../reference/portion.html">portion_IR()</a></code>, to comply with EUCAST insights</li>
 | 
					<li>Function <code><a href="../reference/availability.html">availability()</a></code> now uses <code><a href="../reference/portion.html">portion_R()</a></code> instead of <code><a href="../reference/portion.html">portion_IR()</a></code>, to comply with EUCAST insights</li>
 | 
				
			||||||
<li>Functions <code><a href="../reference/age.html">age()</a></code> and <code><a href="../reference/age_groups.html">age_groups()</a></code> now have a <code>na.rm</code> parameter to remove empty values</li>
 | 
					<li>Functions <code><a href="../reference/age.html">age()</a></code> and <code><a href="../reference/age_groups.html">age_groups()</a></code> now have a <code>na.rm</code> parameter to remove empty values</li>
 | 
				
			||||||
<li>Renamed function <code><a href="../reference/AMR-deprecated.html">p.symbol()</a></code> to <code><a href="../reference/p_symbol.html">p_symbol()</a></code> (the former is now deprecated and will be removed in a future version)</li>
 | 
					<li>Renamed function <code><a href="../reference/AMR-deprecated.html">p.symbol()</a></code> to <code><a href="../reference/p_symbol.html">p_symbol()</a></code> (the former is now deprecated and will be removed in a future version)</li>
 | 
				
			||||||
 | 
					<li>Using negative values for <code>x</code> in <code><a href="../reference/age_groups.html">age_groups()</a></code> will now introduce <code>NA</code>s and not return an error anymore</li>
 | 
				
			||||||
 | 
					<li>Fix for determining the system’s language</li>
 | 
				
			||||||
 | 
					<li>Fix for <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> on foreign systems</li>
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
<div id="other" class="section level4">
 | 
					<div id="other" class="section level4">
 | 
				
			||||||
<h4 class="hasAnchor">
 | 
					<h4 class="hasAnchor">
 | 
				
			||||||
@@ -1261,7 +1264,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
 | 
				
			|||||||
    <div id="tocnav">
 | 
					    <div id="tocnav">
 | 
				
			||||||
      <h2>Contents</h2>
 | 
					      <h2>Contents</h2>
 | 
				
			||||||
      <ul class="nav nav-pills nav-stacked">
 | 
					      <ul class="nav nav-pills nav-stacked">
 | 
				
			||||||
        <li><a href="#amr-0-7-1-9071">0.7.1.9071</a></li>
 | 
					        <li><a href="#amr-0-7-1-9072">0.7.1.9072</a></li>
 | 
				
			||||||
        <li><a href="#amr-0-7-1">0.7.1</a></li>
 | 
					        <li><a href="#amr-0-7-1">0.7.1</a></li>
 | 
				
			||||||
        <li><a href="#amr-0-7-0">0.7.0</a></li>
 | 
					        <li><a href="#amr-0-7-0">0.7.0</a></li>
 | 
				
			||||||
        <li><a href="#amr-0-6-1">0.6.1</a></li>
 | 
					        <li><a href="#amr-0-6-1">0.6.1</a></li>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -80,7 +80,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">0.7.1.9071</span>
 | 
					        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9072</span>
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -80,7 +80,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">0.7.1.9070</span>
 | 
					        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9072</span>
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -80,7 +80,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">0.7.1.9070</span>
 | 
					        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9072</span>
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,7 +78,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">0.7.1.9071</span>
 | 
					        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9072</span>
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -80,7 +80,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">0.7.1.9071</span>
 | 
					        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9072</span>
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -80,7 +80,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">0.7.1.9055</span>
 | 
					        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9072</span>
 | 
				
			||||||
      </span>
 | 
					      </span>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -297,7 +297,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      <footer>
 | 
					      <footer>
 | 
				
			||||||
      <div class="copyright">
 | 
					      <div class="copyright">
 | 
				
			||||||
  <p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
 | 
					  <p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div class="pkgdown">
 | 
					<div class="pkgdown">
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
% Generated by roxygen2: do not edit by hand
 | 
					% Generated by roxygen2: do not edit by hand
 | 
				
			||||||
% Please edit documentation in R/get_locale.R
 | 
					% Please edit documentation in R/translate.R
 | 
				
			||||||
\name{translate}
 | 
					\name{translate}
 | 
				
			||||||
\alias{translate}
 | 
					\alias{translate}
 | 
				
			||||||
\alias{get_locale}
 | 
					\alias{get_locale}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,6 +30,8 @@ test_that("data sets are valid", {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  # check cross table reference
 | 
					  # check cross table reference
 | 
				
			||||||
  expect_true(all(microorganisms.codes$mo %in% microorganisms$mo))
 | 
					  expect_true(all(microorganisms.codes$mo %in% microorganisms$mo))
 | 
				
			||||||
 | 
					  expect_false(any(is.na(microorganisms.codes$code)))
 | 
				
			||||||
 | 
					  expect_false(any(is.na(microorganisms.codes$mo)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # antibiotic names must always be coercible to their original AB code
 | 
					  # antibiotic names must always be coercible to their original AB code
 | 
				
			||||||
  expect_identical(antibiotics$ab, as.ab(antibiotics$name))
 | 
					  expect_identical(antibiotics$ab, as.ab(antibiotics$name))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,4 +30,7 @@ test_that("keyantibiotics work", {
 | 
				
			|||||||
  expect_false(key_antibiotics_equal("SSS", "SIS", ignore_I = FALSE))
 | 
					  expect_false(key_antibiotics_equal("SSS", "SIS", ignore_I = FALSE))
 | 
				
			||||||
  expect_true(key_antibiotics_equal(".SS", "SI.", ignore_I = TRUE))
 | 
					  expect_true(key_antibiotics_equal(".SS", "SI.", ignore_I = TRUE))
 | 
				
			||||||
  expect_false(key_antibiotics_equal(".SS", "SI.", ignore_I = FALSE))
 | 
					  expect_false(key_antibiotics_equal(".SS", "SI.", ignore_I = FALSE))
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  library(dplyr)
 | 
				
			||||||
 | 
					  expect_warning(key_antibiotics(example_isolates %>% slice(rep(1, 10))))
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,7 +22,7 @@
 | 
				
			|||||||
context("like.R")
 | 
					context("like.R")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test_that("`like` works", {
 | 
					test_that("`like` works", {
 | 
				
			||||||
  expect_true(suppressWarnings("test" %like% c("^t", "^s")))
 | 
					  expect_true(sum("test" %like% c("^t", "^s")) == 1)
 | 
				
			||||||
  expect_true("test" %like% "test")
 | 
					  expect_true("test" %like% "test")
 | 
				
			||||||
  expect_true("test" %like% "TEST")
 | 
					  expect_true("test" %like% "TEST")
 | 
				
			||||||
  expect_true(as.factor("test") %like% "TEST")
 | 
					  expect_true(as.factor("test") %like% "TEST")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user