From 203bc2c665029292765ee29f59f19cde7d467b5a Mon Sep 17 00:00:00 2001 From: mtennekes Date: Fri, 26 Apr 2024 08:45:48 +0200 Subject: [PATCH] fixed #867, also fixed bug in convert2density checks --- R/step1_helper_facets.R | 2 +- R/step4_helper_legends.R | 2 +- R/v4_v3.R | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/R/step1_helper_facets.R b/R/step1_helper_facets.R index a88d2d9c..fa2fd05e 100644 --- a/R/step1_helper_facets.R +++ b/R/step1_helper_facets.R @@ -336,7 +336,7 @@ step1_rearrange_facets = function(tmo, o) { if (is.null(sunit)) sunit = o$unit shape.unit <- ifelse(sunit=="metric", "km", ifelse(sunit=="imperial", "mi", sunit)) u = paste(shape.unit, shape.unit) - shp[[v]] = shp[[v]] / units::set_units(shp$AREA, u, mode = "standard") + if (is.numeric(shp[[v]])) shp[[v]] = shp[[v]] / units::set_units(shp$AREA, u, mode = "standard") } } diff --git a/R/step4_helper_legends.R b/R/step4_helper_legends.R index c88b91f9..94f4e689 100644 --- a/R/step4_helper_legends.R +++ b/R/step4_helper_legends.R @@ -55,7 +55,7 @@ step4_plot_collect_legends = function(tmx) { # find shared legends icon_scales = vapply(legs2, function(l) { - as.numeric(l$icon_scale) + as.numeric(l$icon_scale[1]) }, FUN.VALUE = numeric(1)) icon_scale = if (any(icon_scales != 1)) icon_scales[which(icon_scales != 1)[1]] else 1 diff --git a/R/v4_v3.R b/R/v4_v3.R index 47ff09c4..ee717fc9 100644 --- a/R/v4_v3.R +++ b/R/v4_v3.R @@ -21,6 +21,10 @@ v3_use_component = function(arg = "title", comp = "tm_title", container = "tm_fo message(paste0("[v3->v4] ", container, "(): use ", comp, "() instead of the argument '", arg, "'")) } +v3_convert2density = function(layer_fun) { + message(paste0("[v3->v4] ", layer_fun, "(): convert2density is deprecated: divide the variable values by the polygon areas manually (obtain the areas with 'sf::st_area()')")) +} + v3_tm_scale_instead_of_style = function(style, scale_fun, vv, layer_fun, arg_list) { if (scale_fun == "intervals") { arg_list$old = c("style", arg_list$old)