From dc4eed7d5c3b326ffefef3288afe62cef7119706 Mon Sep 17 00:00:00 2001 From: aho Date: Wed, 15 Jun 2022 09:48:19 +0200 Subject: [PATCH] Bugfix for 'var' as list --- DESCRIPTION | 2 +- R/PlotLayout.R | 15 ++++++++++++++- man/PlotLayout.Rd | 15 ++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9690f44..68a4320 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -47,4 +47,4 @@ BugReports: https://earth.bsc.es/gitlab/es/s2dv/-/issues LazyData: true SystemRequirements: cdo Encoding: UTF-8 -RoxygenNote: 7.0.1 +RoxygenNote: 7.2.0 diff --git a/R/PlotLayout.R b/R/PlotLayout.R index 50a87f2..b6bc467 100644 --- a/R/PlotLayout.R +++ b/R/PlotLayout.R @@ -56,6 +56,19 @@ #' b) providing a list of named sub-lists in 'special_args', where the names #' of each sub-list match the names of the parameters to be adjusted, and #' each value in a sub-list contains the value of the corresponding parameter. +#' For example, if the plots are two maps with different arguments, the +#' structure would be like:\n +#' var:\n +#' List of 2\n +#' $ : num [1:360, 1:181] 1 3.82 5.02 6.63 8.72 ...\n +#' $ : num [1:360, 1:181] 2.27 2.82 4.82 7.7 10.32 ...\n +#' special_args:\n +#' List of 2\n +#' $ :List of 2\n +#' ..$ arg1: ...\n +#' ..$ arg2: ...\n +#' $ :List of 1\n +#' ..$ arg1: ...\n #'@param nrow Numeric value to force the number of rows in the automatically #' generated layout. If higher than the required, this will yield blank cells #' in the layout (which can then be populated). If lower than the required @@ -225,7 +238,7 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, is_single_na <- function(x) ifelse(length(x) > 1, FALSE, is.na(x)) # Check var - if (is.array(var) || (is_single_na(var))) { + if (!is.list(var) & (is.array(var) || (is_single_na(var)))) { var <- list(var) } else if (is.list(var)) { if (!all(sapply(var, is.array) | sapply(var, is_single_na))) { diff --git a/man/PlotLayout.Rd b/man/PlotLayout.Rd index 10bb39e..eaa2197 100644 --- a/man/PlotLayout.Rd +++ b/man/PlotLayout.Rd @@ -94,7 +94,20 @@ a) splitting your array into a list of sub-arrays (each with the data for one plot) and providing it as parameter 'var', b) providing a list of named sub-lists in 'special_args', where the names of each sub-list match the names of the parameters to be adjusted, and -each value in a sub-list contains the value of the corresponding parameter.} +each value in a sub-list contains the value of the corresponding parameter. +For example, if the plots are two maps with different arguments, the +structure would be like:\n +var:\n + List of 2\n + $ : num [1:360, 1:181] 1 3.82 5.02 6.63 8.72 ...\n + $ : num [1:360, 1:181] 2.27 2.82 4.82 7.7 10.32 ...\n +special_args:\n + List of 2\n + $ :List of 2\n + ..$ arg1: ...\n + ..$ arg2: ...\n + $ :List of 1\n + ..$ arg1: ...\n} \item{nrow}{Numeric value to force the number of rows in the automatically generated layout. If higher than the required, this will yield blank cells -- GitLab