Skip to content

Commit

Permalink
Merge pull request #870 from r-tmap/man
Browse files Browse the repository at this point in the history
Document missing arguments
  • Loading branch information
Nowosad authored May 3, 2024
2 parents a860238 + 0dc7ef5 commit 4f7d5ae
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 30 deletions.
10 changes: 2 additions & 8 deletions R/tm_facets.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions R/tm_scale_.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 3 additions & 10 deletions man/tm_facets.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/tm_scale_continuous.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 14 additions & 12 deletions tests/testthat/test-v3.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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", {
Expand All @@ -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",
Expand All @@ -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"))
})

0 comments on commit 4f7d5ae

Please sign in to comment.