mirror of
				https://github.com/msberends/AMR.git
				synced 2025-10-31 10:08:12 +01:00 
			
		
		
		
	(v3.0.0.9031) fix for ggplot2
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| Package: AMR | Package: AMR | ||||||
| Version: 3.0.0.9030 | Version: 3.0.0.9031 | ||||||
| Date: 2025-09-11 | Date: 2025-09-12 | ||||||
| Title: Antimicrobial Resistance Data Analysis | Title: Antimicrobial Resistance Data Analysis | ||||||
| Description: Functions to simplify and standardise antimicrobial resistance (AMR) | Description: Functions to simplify and standardise antimicrobial resistance (AMR) | ||||||
|   data analysis and to work with microbial and antimicrobial properties by |   data analysis and to work with microbial and antimicrobial properties by | ||||||
| @@ -70,5 +70,5 @@ BugReports: https://github.com/msberends/AMR/issues | |||||||
| License: GPL-2 | file LICENSE | License: GPL-2 | file LICENSE | ||||||
| Encoding: UTF-8 | Encoding: UTF-8 | ||||||
| LazyData: true | LazyData: true | ||||||
| RoxygenNote: 7.3.2 | RoxygenNote: 7.3.3 | ||||||
| Roxygen: list(markdown = TRUE, old_usage = TRUE) | Roxygen: list(markdown = TRUE, old_usage = TRUE) | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								NEWS.md
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								NEWS.md
									
									
									
									
									
								
							| @@ -1,8 +1,9 @@ | |||||||
| # AMR 3.0.0.9030 | # AMR 3.0.0.9031 | ||||||
|  |  | ||||||
| This is a bugfix release following the release of v3.0.0 in June 2025. | This is a bugfix release following the release of v3.0.0 in June 2025. | ||||||
|  |  | ||||||
| ### Changed | ### Changed | ||||||
|  | * Allow support for newest `ggplot2` v4.0.0 | ||||||
| * Fixed a bug in `antibiogram()` for when no antimicrobials are set | * Fixed a bug in `antibiogram()` for when no antimicrobials are set | ||||||
| * Fixed a bug in `antibiogram()` to allow column names containing the `+` character (#222) | * Fixed a bug in `antibiogram()` to allow column names containing the `+` character (#222) | ||||||
| * Fixed a bug in `as.ab()` for antimicrobial codes with a number in it if they are preceded by a space | * Fixed a bug in `as.ab()` for antimicrobial codes with a number in it if they are preceded by a space | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								R/plotting.R
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								R/plotting.R
									
									
									
									
									
								
							| @@ -247,6 +247,7 @@ create_scale_mic <- function(aest, keep_operators, mic_range = NULL, ...) { | |||||||
|     as.double(rescale_mic(x = as.double(as.mic(x)), keep_operators = keep_operators, mic_range = mic_range, as.mic = TRUE)) |     as.double(rescale_mic(x = as.double(as.mic(x)), keep_operators = keep_operators, mic_range = mic_range, as.mic = TRUE)) | ||||||
|   } |   } | ||||||
|   scale$transform_df <- function(self, df) { |   scale$transform_df <- function(self, df) { | ||||||
|  |     out <- list() | ||||||
|     if (!aest %in% colnames(df)) { |     if (!aest %in% colnames(df)) { | ||||||
|       # support for geom_hline(), geom_vline(), etc |       # support for geom_hline(), geom_vline(), etc | ||||||
|       other_x <- c("xintercept", "xmin", "xmax", "xend", "width") |       other_x <- c("xintercept", "xmin", "xmax", "xend", "width") | ||||||
| @@ -258,11 +259,11 @@ create_scale_mic <- function(aest, keep_operators, mic_range = NULL, ...) { | |||||||
|       } else { |       } else { | ||||||
|         stop_("No support for plotting df with `scale_", aest, "_mic()` with columns ", vector_and(colnames(df), sort = FALSE)) |         stop_("No support for plotting df with `scale_", aest, "_mic()` with columns ", vector_and(colnames(df), sort = FALSE)) | ||||||
|       } |       } | ||||||
|       out <- rescale_mic(x = as.double(as.mic(df[[aest_val]])), keep_operators = "none", mic_range = NULL, as.mic = TRUE) |       mics <- rescale_mic(x = as.double(as.mic(df[[aest_val]])), keep_operators = "none", mic_range = NULL, as.mic = TRUE) | ||||||
|       if (!is.null(self$mic_values_rescaled) && any(out < min(self$mic_values_rescaled, na.rm = TRUE) | out > max(self$mic_values_rescaled, na.rm = TRUE), na.rm = TRUE)) { |       if (!is.null(self$mic_values_rescaled) && any(mics < min(self$mic_values_rescaled, na.rm = TRUE) | mics > max(self$mic_values_rescaled, na.rm = TRUE), na.rm = TRUE)) { | ||||||
|         warning_("The value for `", aest_val, "` is outside the plotted MIC range, consider using/updating the `mic_range` argument in `scale_", aest, "_mic()`.") |         warning_("The value for `", aest_val, "` is outside the plotted MIC range, consider using/updating the `mic_range` argument in `scale_", aest, "_mic()`.") | ||||||
|       } |       } | ||||||
|       df[[aest_val]] <- log2(as.double(out)) |       out[[aest_val]] <- log2(as.double(mics)) | ||||||
|     } else { |     } else { | ||||||
|       self$mic_values_rescaled <- rescale_mic(x = as.double(as.mic(df[[aest]])), keep_operators = keep_operators, mic_range = mic_range, as.mic = TRUE) |       self$mic_values_rescaled <- rescale_mic(x = as.double(as.mic(df[[aest]])), keep_operators = keep_operators, mic_range = mic_range, as.mic = TRUE) | ||||||
|       # create new breaks and labels here |       # create new breaks and labels here | ||||||
| @@ -286,11 +287,11 @@ create_scale_mic <- function(aest, keep_operators, mic_range = NULL, ...) { | |||||||
|  |  | ||||||
|       self$mic_values_log <- log2(as.double(self$mic_values_rescaled)) |       self$mic_values_log <- log2(as.double(self$mic_values_rescaled)) | ||||||
|       if (aest == "y" && "group" %in% colnames(df) && "x" %in% colnames(df)) { |       if (aest == "y" && "group" %in% colnames(df) && "x" %in% colnames(df)) { | ||||||
|         df$group <- as.integer(factor(df$x)) |         out$group <- as.integer(factor(df$x)) | ||||||
|       } |       } | ||||||
|       df[[aest]] <- self$mic_values_log |       out[[aest]] <- self$mic_values_log | ||||||
|     } |     } | ||||||
|     df |     out | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   scale$breaks <- function(..., self) { |   scale$breaks <- function(..., self) { | ||||||
| @@ -317,7 +318,6 @@ create_scale_mic <- function(aest, keep_operators, mic_range = NULL, ...) { | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   scale$limits <- function(x, ..., self) { |   scale$limits <- function(x, ..., self) { | ||||||
|     if (!is.null(self$mic_limits_set)) { |     if (!is.null(self$mic_limits_set)) { | ||||||
|       if (is.function(self$mic_limits_set)) { |       if (is.function(self$mic_limits_set)) { | ||||||
|   | |||||||
| @@ -77,7 +77,7 @@ test_that("test-misc.R", { | |||||||
|   if (!is_right) { |   if (!is_right) { | ||||||
|     # otherwise, this is needed for older versions |     # otherwise, this is needed for older versions | ||||||
|     df <- example_isolates[c(1:3), check_df("xx")] |     df <- example_isolates[c(1:3), check_df("xx")] | ||||||
|     expect_true(is_right, info = "the environmental data cannot be found for base `x` or `xx`")  |     expect_true(is_right, info = "the environmental data cannot be found for base `x` or `xx`") | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE)) { |   if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user