diff --git a/DESCRIPTION b/DESCRIPTION
index 5d3a85e8..2791bafc 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: AMR
-Version: 1.2.0.9002
-Date: 2020-06-03
+Version: 1.2.0.9003
+Date: 2020-06-05
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(role = c("aut", "cre"),
diff --git a/NEWS.md b/NEWS.md
index 048dc9b3..9e8fac12 100755
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,5 @@
-# AMR 1.2.0.9002
-## Last updated: 03-Jun-2020
+# AMR 1.2.0.9003
+## Last updated: 05-Jun-2020
### Changed
* Fixed a bug where `eucast_rules()` would not work on a tibble when the `tibble` or `dplyr` package was loaded
diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R
index 28f5860f..8c926c2f 100755
--- a/R/aa_helper_functions.R
+++ b/R/aa_helper_functions.R
@@ -250,26 +250,63 @@ dataset_UTF8_to_ASCII <- function(df) {
df
}
-
-# replace crayon::has_color, but now also FALSE on non-interactive mode
-has_colour <- function() {
- if (Sys.getenv("TERM") == "dumb" | !interactive()) {
+has_colour <- function () {
+ # this is a base R version of crayon::has_color
+ enabled <- getOption("crayon.enabled")
+ if (!is.null(enabled)) {
+ return(isTRUE(enabled))
+ }
+ rstudio_with_ansi_support <- function(x) {
+ if (Sys.getenv("RSTUDIO", "") == "") {
+ return(FALSE)
+ }
+ if ((cols <- Sys.getenv("RSTUDIO_CONSOLE_COLOR", "")) != "" && !is.na(as.numeric(cols))) {
+ return(TRUE)
+ }
+ tryCatch(get("isAvailable", envir = asNamespace("rstudioapi"))(), error = function(e) return(FALSE)) &&
+ tryCatch(get("hasFun", envir = asNamespace("rstudioapi"))("getConsoleHasColor"), error = function(e) return(FALSE))
+ }
+ if (rstudio_with_ansi_support() && sink.number() == 0) {
+ return(TRUE)
+ }
+ if (!isatty(stdout())) {
return(FALSE)
}
if (tolower(Sys.info()["sysname"]) == "windows") {
- if (Sys.getenv("ConEmuANSI") == "ON" | Sys.getenv("CMDER_ROOT") != "") {
+ if (Sys.getenv("ConEmuANSI") == "ON") {
return(TRUE)
- } else {
- return(FALSE)
}
+ if (Sys.getenv("CMDER_ROOT") != "") {
+ return(TRUE)
+ }
+ return(FALSE)
}
- "COLORTERM" %in% names(Sys.getenv()) | grepl("^screen|^xterm|^vt100|color|ansi|cygwin|linux",
- Sys.getenv("TERM"),
- ignore.case = TRUE,
- perl = TRUE)
+ emacs_version <- function () {
+ ver <- Sys.getenv("INSIDE_EMACS")
+ if (ver == "") {
+ return(NA_integer_)
+ }
+ ver <- gsub("'", "", ver)
+ ver <- strsplit(ver, ",", fixed = TRUE)[[1]]
+ ver <- strsplit(ver, ".", fixed = TRUE)[[1]]
+ as.numeric(ver)
+ }
+ if ((Sys.getenv("EMACS") != "" || Sys.getenv("INSIDE_EMACS") != "") &&
+ !is.na(emacs_version()[1]) && emacs_version()[1] >= 23) {
+ return(TRUE)
+ }
+ if ("COLORTERM" %in% names(Sys.getenv())) {
+ return(TRUE)
+ }
+ if (Sys.getenv("TERM") == "dumb") {
+ return(FALSE)
+ }
+ grepl(pattern = "^screen|^xterm|^vt100|color|ansi|cygwin|linux",
+ x = Sys.getenv("TERM"),
+ ignore.case = TRUE,
+ perl = TRUE)
}
-
# the crayon colours
try_colour <- function(..., before, after, collapse = " ") {
txt <- paste0(unlist(list(...)), collapse = collapse)
diff --git a/R/eucast_rules.R b/R/eucast_rules.R
index efc39c49..713e87a3 100755
--- a/R/eucast_rules.R
+++ b/R/eucast_rules.R
@@ -614,7 +614,7 @@ eucast_rules <- function(x,
if (info == TRUE) {
cat(font_bold(paste0("\nRules by this AMR package (",
font_red(paste0("v", utils::packageVersion("AMR"), ", ",
- format(utils::packageDate("AMR"), "%Y"))), ")\n")))
+ format(utils::packageDate("AMR"), "%Y"))), "), see ?eucast_rules\n")))
}
ab_enzyme <- subset(antibiotics, name %like% "/")[, c("ab", "name")]
diff --git a/R/filter_ab_class.R b/R/filter_ab_class.R
index 5af90618..9d51b6e9 100644
--- a/R/filter_ab_class.R
+++ b/R/filter_ab_class.R
@@ -101,6 +101,7 @@ filter_ab_class <- function(x,
return(x.bak)
}
# get reference data
+ ab_class.bak <- ab_class
ab_class <- gsub("[^a-zA-Z0-9]+", ".*", ab_class)
ab_class <- gsub("(ph|f)", "(ph|f)", ab_class)
ab_class <- gsub("(t|th)", "(t|th)", ab_class)
@@ -109,6 +110,10 @@ filter_ab_class <- function(x,
atc_group1 %like% ab_class |
atc_group2 %like% ab_class)
ab_group <- find_ab_group(ab_class)
+ if (ab_group == "") {
+ message(font_blue(paste0("NOTE: unknown antimicrobial class '", ab_class.bak, "', data left unchanged.")))
+ return(x.bak)
+ }
# get the columns with a group names in the chosen ab class
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
if (length(agents) == 0) {
diff --git a/data-raw/country_analysis.R b/data-raw/country_analysis.R
index 44a22bf1..11e90808 100644
--- a/data-raw/country_analysis.R
+++ b/data-raw/country_analysis.R
@@ -127,12 +127,12 @@ countries_plot <- ggplot(countries_geometry) +
countries_plot_mini <- countries_plot
countries_plot_mini$data <- countries_plot_mini$data %>% filter(ID != "Antarctica")
-countries_plot_mini <- countries_plot_mini + scale_colour_gradient(low = "#81899B", high = "#81899B")
+# countries_plot_mini <- countries_plot_mini + scale_colour_gradient(low = "#81899B", high = "#81899B")
countries_plot_big <- countries_plot +
- labs(title = tools::toTitleCase("Countries where the AMR package for R was downloaded from"),
- subtitle = paste0("Between March 2018 (first release) and ", format(Sys.Date(), "%B %Y"), "." #,
- #"The dots denote visitors on our website https://gitlab.io/msberends/AMR."
- )) +
+ labs(title = tools::toTitleCase("Countries the AMR package for R was downloaded from"),
+ subtitle = paste0("Between March 2018 (first release) and ",
+ format(Sys.Date(), "%B %Y")),
+ caption = "Source: https://cran-logs.rstudio.com") +
theme(plot.title = element_text(size = 16, hjust = 0.5),
plot.subtitle = element_text(size = 12, hjust = 0.5)) +
geom_text(aes(x = -170,
@@ -142,12 +142,7 @@ countries_plot_big <- countries_plot +
paste(sort(countries_name[!is.na(countries_name)]), collapse = ", ")),
200)),
hjust = 0,
- size = 4) # +
- # # points of visitors
- # geom_point(data = ip_tbl,
- # aes(x = x, y = y),
- # size = 1,
- # colour = "#81899B")
+ size = 4)
# main website page
ggsave("pkgdown/logos/countries.png",
diff --git a/docs/404.html b/docs/404.html
index 8e486d95..717e30f7 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -81,7 +81,7 @@
NEWS.md
-