diff --git a/R/tm_facets.R b/R/tm_facets.R index b9133174..720504f0 100644 --- a/R/tm_facets.R +++ b/R/tm_facets.R @@ -29,18 +29,12 @@ #' and columns are dropped. #' @param drop.NA.facets Logical. If the `by` argument is specified, and all #' data values for specific facets are missing, should these facets be dropped? -#' `FALSE` by default. +#' `FALSE` by default. In v3, it was called `showNA`. #' @param sync Logical. Should the navigation in view mode (zooming and panning) #' be synchronized? By default `TRUE` if the facets have the same bounding box. #' This is generally the case when rasters are plotted, or when `free.coords` is #' `FALSE`. -#' @param showNA If the `by` argument is specified, should missing values of the -#' `by`-variable be shown in a facet? If two `by`-variables are specified, -#' should missing values be shown in an additional row and column? -#' If `NA`, missing values only are shown if they exist. Similar to the -#' `useNA` argument of [table()][base::table()], where `TRUE`, `FALSE`, -#' and `NA` correspond to `"always"`, `"no"`, and `"ifany"` respectively. -#' @param textNA Text used for facets of missing values. +#' @param na.text Text used for facets of missing values. In v3, it was `textNA`. #' @param scale.factor Number that determines how the elements (e.g. font sizes, #' symbol sizes, line widths) of the small multiples are scaled in relation to #' the scaling factor of the shapes. The elements are scaled to the `scale.factor`th diff --git a/R/tm_scale_.R b/R/tm_scale_.R index e0df2f6e..da3850dd 100644 --- a/R/tm_scale_.R +++ b/R/tm_scale_.R @@ -222,6 +222,8 @@ tm_scale_discrete = function(ticks = NA, #' @param label.na (generic scale argument) Label for missing values #' @param label.null (generic scale argument) Label for null (out-of-scope) values #' @param label.format (generic scale argument) Label formatting (similar to `legend.format` in tmap3) +#' @param trans.args list of additional argument for the transformation (generic transformation arguments) +#' @inheritParams scales::transform_pseudo_log #' @export #' @rdname tm_scale_continuous #' @name tm_scale_continuous diff --git a/man/tm_facets.Rd b/man/tm_facets.Rd index 54131b08..1e573274 100644 --- a/man/tm_facets.Rd +++ b/man/tm_facets.Rd @@ -84,13 +84,15 @@ and columns are dropped.} \item{drop.NA.facets}{Logical. If the \code{by} argument is specified, and all data values for specific facets are missing, should these facets be dropped? -\code{FALSE} by default.} +\code{FALSE} by default. In v3, it was called \code{showNA}.} \item{sync}{Logical. Should the navigation in view mode (zooming and panning) be synchronized? By default \code{TRUE} if the facets have the same bounding box. This is generally the case when rasters are plotted, or when \code{free.coords} is \code{FALSE}.} +\item{na.text}{Text used for facets of missing values. In v3, it was \code{textNA}.} + \item{scale.factor}{Number that determines how the elements (e.g. font sizes, symbol sizes, line widths) of the small multiples are scaled in relation to the scaling factor of the shapes. The elements are scaled to the \code{scale.factor}th @@ -106,15 +108,6 @@ By default, \code{scale.factor=2}.} \item{free.scales}{deprecated. Please use the \code{.free} arguments in the layer functions, e.g. \code{fill.free} in \code{tm_polygons}.} \item{...}{passed on to \code{tm_facets()}} - -\item{showNA}{If the \code{by} argument is specified, should missing values of the -\code{by}-variable be shown in a facet? If two \code{by}-variables are specified, -should missing values be shown in an additional row and column? -If \code{NA}, missing values only are shown if they exist. Similar to the -\code{useNA} argument of \link[base:table]{table()}, where \code{TRUE}, \code{FALSE}, -and \code{NA} correspond to \code{"always"}, \code{"no"}, and \code{"ifany"} respectively.} - -\item{textNA}{Text used for facets of missing values.} } \description{ Specify facets. \code{tm_facets()} is the core function, but recommended is to use diff --git a/man/tm_scale_continuous.Rd b/man/tm_scale_continuous.Rd index 4e89d52b..9a92ec6f 100644 --- a/man/tm_scale_continuous.Rd +++ b/man/tm_scale_continuous.Rd @@ -78,7 +78,13 @@ tm_scale_continuous_pseudo_log(..., base = exp(1), sigma = 1) \item{label.format}{(generic scale argument) Label formatting (similar to \code{legend.format} in tmap3)} +\item{trans.args}{list of additional argument for the transformation (generic transformation arguments)} + \item{...}{passed on to \code{tm_scale_continuous}} + +\item{base}{base of logarithm} + +\item{sigma}{Scaling factor for the linear part of pseudo-log transformation.} } \description{ Scales in tmap are configured by the family of functions with prefix \code{tm_scale}. diff --git a/tests/testthat/test-v3.R b/tests/testthat/test-v3.R index 7e939e29..c2ed84b4 100644 --- a/tests/testthat/test-v3.R +++ b/tests/testthat/test-v3.R @@ -51,10 +51,12 @@ test_that("v3 syntax works", { }) test_that("Possible to revert to v3 styling.", { + skip_on_cran() World$HPI[1:10] = NA tm_shape(World) + tm_polygons("economy", style = "cat") - tmap_style("v3") - expect_message(tm_shape(World) + tm_polygons("economy", style = "cat")) + current_style <- tmap_style("v3") + tm_shape(World) + tm_polygons("economy", style = "cat") %>% expect_no_error() + tm_shape(World) + tm_polygons("HPI", style = "cont") %>% expect_no_error() expect_message(tm_shape(World) + tm_polygons("HPI", style = "fixed", breaks = c(0, 20, 35, 42, 50))) @@ -69,8 +71,8 @@ test_that("Possible to revert to v3 styling.", { expect_message(tm_shape(World) + tm_polygons("HPI", style = "jenks")) expect_message(tm_shape(World) + tm_polygons("HPI", style = "dpih")) expect_message(tm_shape(World) + tm_polygons("HPI", style = "headtails")) - expect_message(tm_shape(World) + tm_polygons("HPI", style = "cont")) expect_message(tm_shape(World) + tm_polygons("HPI", style = "log10")) + tmap_style(current_style) }) test_that("log10_pretty and order styles work", { @@ -81,21 +83,22 @@ test_that("log10_pretty and order styles work", { }) test_that("v3 that doesn't work", { - skip("v3 should warn?") - expect_warning({tm_shape(World) + - tm_fill(I("isNLD")) + + skip_on_cran() + World$isNLD <- ifelse(World$name=="Netherlands", "darkorange", "darkolivegreen3") + + expect_message({tm_shape(World) + + tm_fill("isNLD") + tm_layout("Find the Netherlands!")}) }) test_that("title size works with many titles.", { - + skip_on_cran() # Example to illustrate the type of titles # Brought over to make examples work. # The failing test can be resolved later. # the problem is still there for many titles. - skip("Many titles still do not work.") - expect_snapshot({ - tm_shape(World) + + # Many titles now work + expect_no_error(tm_shape(World) + tm_polygons(c("income_grp", "economy"), title = c("Legend Title 1", "Legend Title 2")) + tm_layout(main.title = "Main Title", main.title.position = "center", @@ -104,6 +107,5 @@ test_that("title size works with many titles.", { title.color = "red", panel.labels = c("Panel Label 1", "Panel Label 2"), panel.label.color = "purple", - legend.text.color = "brown") - }) + legend.text.color = "brown")) })