From 75219214f34c64b2fb3371e453d735bd847ada07 Mon Sep 17 00:00:00 2001 From: Damiano Oldoni Date: Mon, 22 Jul 2024 14:24:22 +0200 Subject: [PATCH] Fix #231 --- R/map_dep.R | 54 ++++++------- man/map_dep.Rd | 54 ++++++------- tests/testthat/test-map_dep.R | 86 ++++++++++----------- vignettes/visualize-deployment-features.Rmd | 64 +++++++-------- 4 files changed, 129 insertions(+), 129 deletions(-) diff --git a/R/map_dep.R b/R/map_dep.R index 3f873b1a..c8cc796f 100644 --- a/R/map_dep.R +++ b/R/map_dep.R @@ -110,27 +110,27 @@ #' x <- example_dataset() #' #' # Show number of species -#' map_dep( +#' map_deployments( #' x, #' "n_species" #' ) #' #' # Show number of observations (observations of unidentified species included #' # if any) -#' map_dep( +#' map_deployments( #' x, #' "n_obs" #' ) #' #' # Show number of observations of Anas platyrhynchos -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' species = "Anas platyrhynchos" #' ) #' #' # Show number of observations of subadult individuals of Anas strepera -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' species = "Anas strepera", @@ -138,7 +138,7 @@ #' ) #' #' # Show number of observations of female or unknown individuals of gadwall -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' species = "gadwall", @@ -147,13 +147,13 @@ #' #' # Show number of individuals (individuals of unidentified species included if #' # any) -#' map_dep( +#' map_deployments( #' x, #' "n_individuals" #' ) #' #' # Same filters by life stage and sex as for number of observations apply -#' map_dep( +#' map_deployments( #' x, #' "n_individuals", #' species = "Anas strepera", @@ -162,14 +162,14 @@ #' ) #' #' # Show RAI -#' map_dep( +#' map_deployments( #' x, #' "rai", #' species = "Anas strepera" #' ) #' #' # Same filters by life_stage and sex as for number of observations apply -#' map_dep( +#' map_deployments( #' x, #' "rai", #' species = "Anas strepera", @@ -178,14 +178,14 @@ #' ) #' #' # Show RAI calculated by using number of detected individuals -#' map_dep( +#' map_deployments( #' x, #' "rai_individuals", #' species = "Anas strepera" #' ) #' #' # Same filters by life stage and sex as for basic RAI apply -#' map_dep( +#' map_deployments( #' x, #' "rai_individuals", #' species = "Anas strepera", @@ -194,47 +194,47 @@ #' ) #' #' # Show effort (hours) -#' map_dep( +#' map_deployments( #' x, #' "effort" #' ) #' # Show effort (days) -#' map_dep( +#' map_deployments( #' x, #' "effort", #' effort_unit = "day" #' ) #' #' # Use viridis palette (viridis palettes) -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' palette = "viridis" #' ) #' #' # Use "BuPu" colour palette (RColorBrewer palettes) -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' palette = "BuPu" #' ) #' #' # Use a palette defined by colour names -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' palette = c("black", "blue", "white") #' ) #' #' # Use a palette defined by hex colours -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' palette = c("#000000", "#0000FF", "#FFFFFF") #' ) #' #' # Do not show deployments with zero values -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' life_stage = "subadult", @@ -243,7 +243,7 @@ #' #' # Use same icon but but a non default colour for zero values deployments, #' # E.g. red (hex: E74C3C) -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' life_stage = "subadult", @@ -251,7 +251,7 @@ #' ) #' #' # ... or yellow (F1C40F) -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' life_stage = "subadult", @@ -260,7 +260,7 @@ #' #' # Use another icon via a different URL, e.g. the character Fry from Futurama #' # in green (2ECC71) -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' life_stage = "subadult", @@ -277,7 +277,7 @@ #' # A deployment has no observations #' filter(deploymentID != "62c200a9-0e03-4495-bcd8-032944f6f5a1") #' # create new map -#' map_dep( +#' map_deployments( #' unknown_species_vs_no_obs, #' feature = "n_species", #' zero_values_icon_url = "https://img.icons8.com/ios-glyphs/30/2ECC71/futurama-fry.png", @@ -287,7 +287,7 @@ #' ) #' #' # Set size of the icon for zero values deployments -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' life_stage = "subadult", @@ -295,28 +295,28 @@ #' ) #' #' # Disable cluster -#' map_dep( +#' map_deployments( #' x, #' "n_species", #' cluster = FALSE #' ) #' #' # Show only number of observations and location name while hovering -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' hover_columns = c("locationName", "n") #' ) #' #' # Use absolute scale for colours and radius -#' map_dep(x, +#' map_deployments(x, #' "n_species", #' relative_scale = FALSE, #' max_scale = 4 #' ) #' #' # Change max and min size circles -#' map_dep( +#' map_deployments( #' x, #' "n_obs", #' radius_range = c(40, 150) diff --git a/man/map_dep.Rd b/man/map_dep.Rd index 4166fcc3..5419dc2c 100644 --- a/man/map_dep.Rd +++ b/man/map_dep.Rd @@ -164,27 +164,27 @@ returned. x <- example_dataset() # Show number of species -map_dep( +map_deployments( x, "n_species" ) # Show number of observations (observations of unidentified species included # if any) -map_dep( +map_deployments( x, "n_obs" ) # Show number of observations of Anas platyrhynchos -map_dep( +map_deployments( x, "n_obs", species = "Anas platyrhynchos" ) # Show number of observations of subadult individuals of Anas strepera -map_dep( +map_deployments( x, "n_obs", species = "Anas strepera", @@ -192,7 +192,7 @@ map_dep( ) # Show number of observations of female or unknown individuals of gadwall -map_dep( +map_deployments( x, "n_obs", species = "gadwall", @@ -201,13 +201,13 @@ map_dep( # Show number of individuals (individuals of unidentified species included if # any) -map_dep( +map_deployments( x, "n_individuals" ) # Same filters by life stage and sex as for number of observations apply -map_dep( +map_deployments( x, "n_individuals", species = "Anas strepera", @@ -216,14 +216,14 @@ map_dep( ) # Show RAI -map_dep( +map_deployments( x, "rai", species = "Anas strepera" ) # Same filters by life_stage and sex as for number of observations apply -map_dep( +map_deployments( x, "rai", species = "Anas strepera", @@ -232,14 +232,14 @@ map_dep( ) # Show RAI calculated by using number of detected individuals -map_dep( +map_deployments( x, "rai_individuals", species = "Anas strepera" ) # Same filters by life stage and sex as for basic RAI apply -map_dep( +map_deployments( x, "rai_individuals", species = "Anas strepera", @@ -248,47 +248,47 @@ map_dep( ) # Show effort (hours) -map_dep( +map_deployments( x, "effort" ) # Show effort (days) -map_dep( +map_deployments( x, "effort", effort_unit = "day" ) # Use viridis palette (viridis palettes) -map_dep( +map_deployments( x, "n_obs", palette = "viridis" ) # Use "BuPu" colour palette (RColorBrewer palettes) -map_dep( +map_deployments( x, "n_obs", palette = "BuPu" ) # Use a palette defined by colour names -map_dep( +map_deployments( x, "n_obs", palette = c("black", "blue", "white") ) # Use a palette defined by hex colours -map_dep( +map_deployments( x, "n_obs", palette = c("#000000", "#0000FF", "#FFFFFF") ) # Do not show deployments with zero values -map_dep( +map_deployments( x, "n_obs", life_stage = "subadult", @@ -297,7 +297,7 @@ map_dep( # Use same icon but but a non default colour for zero values deployments, # E.g. red (hex: E74C3C) -map_dep( +map_deployments( x, "n_obs", life_stage = "subadult", @@ -305,7 +305,7 @@ map_dep( ) # ... or yellow (F1C40F) -map_dep( +map_deployments( x, "n_obs", life_stage = "subadult", @@ -314,7 +314,7 @@ map_dep( # Use another icon via a different URL, e.g. the character Fry from Futurama # in green (2ECC71) -map_dep( +map_deployments( x, "n_obs", life_stage = "subadult", @@ -331,7 +331,7 @@ unknown_species_vs_no_obs$data$observations <- # A deployment has no observations filter(deploymentID != "62c200a9-0e03-4495-bcd8-032944f6f5a1") # create new map -map_dep( +map_deployments( unknown_species_vs_no_obs, feature = "n_species", zero_values_icon_url = "https://img.icons8.com/ios-glyphs/30/2ECC71/futurama-fry.png", @@ -341,7 +341,7 @@ map_dep( ) # Set size of the icon for zero values deployments -map_dep( +map_deployments( x, "n_obs", life_stage = "subadult", @@ -349,28 +349,28 @@ map_dep( ) # Disable cluster -map_dep( +map_deployments( x, "n_species", cluster = FALSE ) # Show only number of observations and location name while hovering -map_dep( +map_deployments( x, "n_obs", hover_columns = c("locationName", "n") ) # Use absolute scale for colours and radius -map_dep(x, +map_deployments(x, "n_species", relative_scale = FALSE, max_scale = 4 ) # Change max and min size circles -map_dep( +map_deployments( x, "n_obs", radius_range = c(40, 150) diff --git a/tests/testthat/test-map_dep.R b/tests/testthat/test-map_dep.R index 9a320853..6a3193cf 100644 --- a/tests/testthat/test-map_dep.R +++ b/tests/testthat/test-map_dep.R @@ -1,13 +1,13 @@ -test_that("map_dep() returns error when feature is missing", { +test_that("map_deployments() returns error when feature is missing", { skip_if_offline() x <- example_dataset() - expect_error(map_dep(x), + expect_error(map_deployments(x), 'argument "feature" is missing, with no default', fixed = TRUE ) }) -test_that("map_dep() returns error for invalid feature", { +test_that("map_deployments() returns error for invalid feature", { skip_if_offline() x <- example_dataset() valid_inputs <- @@ -22,7 +22,7 @@ test_that("map_dep() returns error for invalid feature", { no_feature <- "not_a_feature" # invalid feature expect_error( - map_dep(x, feature = no_feature), + map_deployments(x, feature = no_feature), paste0( "Invalid value for feature parameter: not_a_feature.\n", "Valid inputs are: n_species, n_obs, n_individuals, rai, ", @@ -32,112 +32,112 @@ test_that("map_dep() returns error for invalid feature", { ) # more than one feature expect_error( - map_dep(x, feature = valid_inputs[1:2]), + map_deployments(x, feature = valid_inputs[1:2]), "`feature` must have length 1", fixed = TRUE ) }) -test_that("map_dep() can handle combinations of arguments", { +test_that("map_deployments() can handle combinations of arguments", { skip_if_offline() x <- example_dataset() expect_warning( - map_dep(x, feature = "n_species", effort_unit = "month"), + map_deployments(x, feature = "n_species", effort_unit = "month"), "`effort_unit` ignored for `feature = n_species`.", fixed = TRUE ) expect_warning( - map_dep(x, feature = "n_species", sex = "male"), + map_deployments(x, feature = "n_species", sex = "male"), "`sex` ignored for `feature = n_species`.", fixed = TRUE ) expect_warning( - map_dep(x, feature = "n_species", life_stage = "subadult"), + map_deployments(x, feature = "n_species", life_stage = "subadult"), "`life_stage` ignored for `feature = n_species`.", fixed = TRUE ) }) -test_that("map_dep() can toggle showing deployments with zero values", { +test_that("map_deployments() can toggle showing deployments with zero values", { skip_if_offline() x <- example_dataset() # expect an error when the toggle has length > 1 - expect_error(map_dep(x, feature = "n_obs", + expect_error(map_deployments(x, feature = "n_obs", zero_values_show = c(TRUE, TRUE)), "zero_values_show must be a logical: TRUE or FALSE.", fixed = TRUE) # expect an error when the toggle is not TRUE or FALSE - expect_error(map_dep(x, feature = "n_obs", + expect_error(map_deployments(x, feature = "n_obs", zero_values_show = "dax"), "zero_values_show must be a logical: TRUE or FALSE.", fixed = TRUE) - expect_error(map_dep(x, feature = "n_obs", + expect_error(map_deployments(x, feature = "n_obs", zero_values_show = NA), "zero_values_show must be a logical: TRUE or FALSE.", fixed = TRUE) - expect_error(map_dep(x, feature = "n_obs", + expect_error(map_deployments(x, feature = "n_obs", zero_values_show = NULL), "zero_values_show must be a logical: TRUE or FALSE.", fixed = TRUE) # expect a message when an url/size is provided but the toggle is off suppressMessages(expect_message( - map_dep(x, feature = "n_obs", zero_values_show = FALSE), + map_deployments(x, feature = "n_obs", zero_values_show = FALSE), "`zero_values_show` is FALSE: `zero_values_icon_url` ignored.", fixed = TRUE )) suppressMessages(expect_message( - map_dep(x, feature = "n_obs", zero_values_show = FALSE), + map_deployments(x, feature = "n_obs", zero_values_show = FALSE), "`zero_values_show` is FALSE: `zero_values_icon_size` is ignored.", fixed = TRUE )) expect_no_message( - map_dep(x,feature = "n_species", zero_values_show = TRUE) + map_deployments(x,feature = "n_species", zero_values_show = TRUE) ) }) -test_that("map_dep() can toggle showing deployments with NA values", { +test_that("map_deployments() can toggle showing deployments with NA values", { skip_if_offline() x <- example_dataset() # expect an error when the toggle has length > 1 - expect_error(map_dep(x, feature = "n_obs", + expect_error(map_deployments(x, feature = "n_obs", na_values_show = c(TRUE, TRUE)), "na_values_show must be a logical: TRUE or FALSE.", fixed = TRUE) # expect an error when the toggle is not TRUE or FALSE - expect_error(map_dep(x, feature = "n_obs", + expect_error(map_deployments(x, feature = "n_obs", na_values_show = "dax"), "na_values_show must be a logical: TRUE or FALSE.", fixed = TRUE) - expect_error(map_dep(x, feature = "n_obs", + expect_error(map_deployments(x, feature = "n_obs", na_values_show = NA), "na_values_show must be a logical: TRUE or FALSE.", fixed = TRUE) - expect_error(map_dep(x, feature = "n_obs", + expect_error(map_deployments(x, feature = "n_obs", na_values_show = NULL), "na_values_show must be a logical: TRUE or FALSE.", fixed = TRUE) # expect a message when an url/size is provided but the toggle is off suppressMessages(expect_message( - map_dep(x, feature = "n_obs", na_values_show = FALSE), + map_deployments(x, feature = "n_obs", na_values_show = FALSE), "`na_values_show` is FALSE: `na_values_icon_url` ignored.", fixed = TRUE )) suppressMessages(expect_message( - map_dep(x, feature = "n_obs", na_values_show = FALSE), + map_deployments(x, feature = "n_obs", na_values_show = FALSE), "`na_values_show` is FALSE: `na_values_icon_size` is ignored.", fixed = TRUE )) expect_no_message( - map_dep(x,feature = "n_species", na_values_show = TRUE) + map_deployments(x,feature = "n_species", na_values_show = TRUE) ) }) -test_that("map_dep() can calculate and get feature values", { +test_that("map_deployments() can calculate and get feature values", { skip_if_offline() x <- example_dataset() no_obs_deployments <- @@ -153,46 +153,46 @@ test_that("map_dep() can calculate and get feature values", { paste(no_obs_deployments, collapse = ", ") ) suppressMessages(expect_message( - map_dep(x, feature = "rai", species = "krakeend"), + map_deployments(x, feature = "rai", species = "krakeend"), glue::glue("There are 3 deployments without observations: {no_obs_deployments_str}"), fixed = TRUE )) suppressMessages(expect_message( - map_dep(x, feature = "rai_individuals", species = "krakeend"), + map_deployments(x, feature = "rai_individuals", species = "krakeend"), glue::glue("There are 3 deployments without observations: {no_obs_deployments_str}"), fixed = TRUE )) expect_warning( - map_dep(x, feature = "n_species", species = "krakeend"), + map_deployments(x, feature = "n_species", species = "krakeend"), "`species` ignored for `feature = n_species`", fixed = TRUE ) }) -test_that("map_dep() allows for scale modifications", { +test_that("map_deployments() allows for scale modifications", { skip_if_offline() x <- example_dataset() - expect_no_warning(map_dep( + expect_no_warning(map_deployments( x, feature = "n_species", max_scale = 0, relative_scale = FALSE )) - expect_warning(map_dep(x, feature = "effort", max_scale = 0), + expect_warning(map_deployments(x, feature = "effort", max_scale = 0), "Relative scale used: max_scale value ignored.", fixed = TRUE ) - expect_error(map_dep(x, feature = "effort", relative_scale = FALSE), + expect_error(map_deployments(x, feature = "effort", relative_scale = FALSE), "If you use an absolute scale, `max_scale` must be a number, not `NULL`.", fixed = TRUE ) }) -test_that("map_dep() allows disabling of hover columns", { +test_that("map_deployments() allows disabling of hover columns", { skip_if_offline() x <- example_dataset() - map_no_hover <- map_dep(x, feature = "effort", hover_columns = NULL) + map_no_hover <- map_deployments(x, feature = "effort", hover_columns = NULL) expect_true( all( @@ -200,7 +200,7 @@ test_that("map_dep() allows disabling of hover columns", { ) ) map_hover <- - map_dep(x, feature = "n_individuals", hover_columns = "scientificName") + map_deployments(x, feature = "n_individuals", hover_columns = "scientificName") expect_true( any( !is.na(map_hover$x$calls[[3]]$args[[11]]) @@ -208,13 +208,13 @@ test_that("map_dep() allows disabling of hover columns", { ) }) -test_that("map_dep() returns a leaflet", { +test_that("map_deployments() returns a leaflet", { skip_if_offline() x <- example_dataset() - expect_s3_class(map_dep(x, feature = "n_species"), c("leaflet", "htmlwidget")) - expect_no_warning(map_dep(x, feature = "n_species")) - expect_no_error(map_dep(x, feature = "n_species")) - expect_no_message(map_dep(x, feature = "n_species")) + expect_s3_class(map_deployments(x, feature = "n_species"), c("leaflet", "htmlwidget")) + expect_no_warning(map_deployments(x, feature = "n_species")) + expect_no_error(map_deployments(x, feature = "n_species")) + expect_no_message(map_deployments(x, feature = "n_species")) }) test_that("Argument datapkg is deprecated: warning returned", { @@ -223,9 +223,9 @@ test_that("Argument datapkg is deprecated: warning returned", { expect_warning( rlang::with_options( lifecycle_verbosity = "warning", - map_dep(datapkg = x, feature = "n_obs") + map_deployments(datapkg = x, feature = "n_obs") ), - "The `datapkg` argument of `map_dep()` is deprecated as of camtraptor 0.16.0.", + "The `datapkg` argument of `map_deployments()` is deprecated as of camtraptor 0.16.0.", fixed = TRUE ) }) diff --git a/vignettes/visualize-deployment-features.Rmd b/vignettes/visualize-deployment-features.Rmd index e1e80cd1..42042209 100644 --- a/vignettes/visualize-deployment-features.Rmd +++ b/vignettes/visualize-deployment-features.Rmd @@ -16,7 +16,7 @@ knitr::opts_chunk$set( ) ``` -This vignette shows how to use function `map_dep()` to visualize important deployment features on a leaflet map: +This vignette shows how to use function `map_deployments()` to visualize important deployment features on a leaflet map: - number of identified species - number of observations @@ -55,10 +55,10 @@ get_species(x) #### Number of species -You can visualize the number of species detected by each deployment by using the function `map_dep()` with `feature` argument set to `n_species`: +You can visualize the number of species detected by each deployment by using the function `map_deployments()` with `feature` argument set to `n_species`: ```{r visualize_n_species_with_clusters_and_default_hover_col} -map_dep(x, +map_deployments(x, feature = "n_species") ``` @@ -67,14 +67,14 @@ map_dep(x, To visualize the number of observations, set `feature` = `n_obs`: ```{r visualize_n_obs_with_clusters_and_default_hover_col} -map_dep(x, +map_deployments(x, feature = "n_obs") ``` You can also specify which species you want to calculate the number of observations: ```{r visualize_n_obs_species} -map_dep(x, +map_deployments(x, feature = "n_obs", species = "Anas platyrhynchos") ``` @@ -84,7 +84,7 @@ Notice how zero values are also visualized by a specific icon for ease detection You can filter by sex: ```{r filter_sex} -map_dep( +map_deployments( x, "n_obs", species = "Anas platyrhynchos", @@ -95,7 +95,7 @@ map_dep( and life stage: ```{r filter_life_stage} -map_dep( +map_deployments( x, "n_obs", life_stage = c("unknown", "subadult") @@ -107,14 +107,14 @@ map_dep( To visualize the number of observed individuals, set `feature` = `n_individuals`: ```{r visualize_n_individuas_with_clusters_and_default_hover_col} -map_dep(x, +map_deployments(x, feature = "n_individuals") ``` As for observations, you can specify a species: ```{r specify_species_individuals} -map_dep(x, +map_deployments(x, feature = "n_individuals", species = "Anas platyrhynchos") ``` @@ -123,7 +123,7 @@ and filter by sex and/or life stage: ```{r filter_sex_individuals} -map_dep( +map_deployments( x, "n_individuals", species = "Anas platyrhynchos", @@ -136,7 +136,7 @@ map_dep( To visualize the Relative Abundance Index (RAI) for a species, set `feature` = `rai` and specify a species using its scientific name: ```{r visualize_rai_with_clusters_and_default_hover_col} -map_dep(x, +map_deployments(x, feature = "rai", species = "Anas platyrhynchos") ``` @@ -146,7 +146,7 @@ map_dep(x, As for number of observations and number of individuals, you can filter by sex and/or life stage: ```{r filter_sex_rai} -map_dep( +map_deployments( x, "rai", species = "Anas platyrhynchos", @@ -157,7 +157,7 @@ map_dep( Common names are allowed as values of `species` as well: ```{r common_name} -map_dep(x, +map_deployments(x, feature = "rai", species = "great herons") ``` @@ -165,7 +165,7 @@ map_dep(x, Values of `species` are also interpreted case insensitive: ```{r arg_species_case_insensitive} -map_dep(x, +map_deployments(x, feature = "rai", species = "CastoR FIBer") ``` @@ -173,7 +173,7 @@ map_dep(x, If `species` is not specified or is wrong, an informative error message listing all valid values is returned: ```{r see_error_message, error = TRUE} -map_dep(x, +map_deployments(x, feature = "rai", species = "This is not a species name") ``` @@ -183,7 +183,7 @@ map_dep(x, You can also visualize the RAI based on number of detected individuals instead of the standard RAI which is based on the number of observations. Set `feature = "rai_individuals"`: ```{r show_rai_individuals} -map_dep(x, +map_deployments(x, feature = "rai_individuals", species = "Anas platyrhynchos") ``` @@ -195,7 +195,7 @@ Everything described in previous section about visualizing RAI holds true for RA Visualize duration of the deployments, also called _effort_, as number of active hours: ```{r effort_in_hours} -map_dep(x, +map_deployments(x, feature = "effort", effort_unit = "hour") ``` @@ -203,7 +203,7 @@ map_dep(x, The same using days as time unit ```{r effort_in_days} -map_dep(x, +map_deployments(x, feature = "effort", effort_unit = "day") ``` @@ -211,7 +211,7 @@ map_dep(x, or months ```{r effort_in_months} -map_dep(x, +map_deployments(x, feature = "effort", effort_unit = "month") ``` @@ -223,7 +223,7 @@ You can specify which information you want to show while hovering with the mouse Here below the lat/lon, the camera height and the tags are shown while hovering: ```{r visualize_with_clusters_spec_hover_col} -map_dep(x, +map_deployments(x, hover_columns = c("latitude", "longitude", "cameraHeight", @@ -235,7 +235,7 @@ map_dep(x, Deactivating both cluster mode and hovering is also possible: ```{r visualize_without_clusters} -map_dep(x, +map_deployments(x, feature = "n_species", cluster = FALSE, hover_columns = NULL) @@ -261,7 +261,7 @@ unknown_species_vs_no_obs$data$observations <- # a deployment has no observations filter(deploymentID != "62c200a9-0e03-4495-bcd8-032944f6f5a1") # create new map -map_dep(unknown_species_vs_no_obs, +map_deployments(unknown_species_vs_no_obs, feature = "n_species") ``` @@ -270,7 +270,7 @@ map_dep(unknown_species_vs_no_obs, The default color palette is a [viridis color palette](https://cran.microsoft.com/snapshot/2017-08-01/web/packages/viridis/vignettes/intro-to-viridis.html) called `"inferno"`. You can specify another viridis color palette, e.g. `"viridis"` or `"magma"`, or a [RColorBrewer](https://renenyffenegger.ch/notes/development/languages/R/packages/RColorBrewer/index) palette, e.g. `"BuPu"` or `"Oranges"`. Below we use the `viridis` color palette: ```{r use_viridis} -map_dep( +map_deployments( x, "n_obs", palette = "viridis" @@ -280,7 +280,7 @@ map_dep( We can use a palette from `RColorBrewer`, e.g. the `"BuPu"` palette: ```{r use_BuPu} -map_dep( +map_deployments( x, "n_obs", palette = "BuPu" @@ -290,7 +290,7 @@ map_dep( Another easy way to specify a palette is to create it by passing a vector of colors as names or hex colors, e.g. `c("black", "blue", "#A3675F")`: ```{r use_black_blue_white} -map_dep( +map_deployments( x, "n_obs", palette = c("black", "blue", "#A3675F") @@ -302,7 +302,7 @@ map_dep( You can pass to `zero_value_icon_url` argument the URL to an icon and to `zero_values_icon_size` the size in pixels of such icon. There are several icon libraries you can choose from. A library with many free icons is [icons8](https://icons8.com/). Here, an example with the icon of Fry from Futurama animation series and icon size 50: ```{r fry_futurama} -map_dep( +map_deployments( x, "n_obs", life_stage = "subadult", @@ -314,7 +314,7 @@ map_dep( Typically the colour is part of the URL. Here below two examples where we change the color of the default icon to green (2ECC71): ```{r specify_zero_colors_value_example_1} -map_dep( +map_deployments( x, "n_obs", life_stage = "subadult", @@ -326,7 +326,7 @@ map_dep( or the INBO fuchsia (#C04384): ```{r specify_zero_colors_value_example_2} -map_dep( +map_deployments( x, "n_obs", life_stage = "subadult", @@ -342,7 +342,7 @@ Modifying the default value (`"black"`) can be useful as the color of deployment You can also modify the upper and lower limit of the circle sizes by specifying `radius_range` (default: `c(10,50`): ```{r change_size_circles} -map_dep(x, +map_deployments(x, feature = "n_obs", radius_range = c(20, 150)) ``` @@ -354,7 +354,7 @@ By default the upper limit of color palette and radius are defined based on the Upper limit lower than number of observations: ```{r low_upper_limit} -map_dep(x, +map_deployments(x, feature = "n_obs", relative_scale = FALSE, max_scale = 2) @@ -363,7 +363,7 @@ map_dep(x, Upper limit higher than number of observations: ```{r high_upper_limit} -map_dep(x, +map_deployments(x, feature = "n_obs", relative_scale = FALSE, max_scale = 50) @@ -374,7 +374,7 @@ map_dep(x, You maybe would like to visualize deployment information for a subset of deployments. To do this, you can use filter predicates. E.g. visualize number of observations for the deployments with longitude equal or higher than 5.6: ```{r example_filter_predicates_map} -map_dep(x, +map_deployments(x, pred_gt("longitude", 5.6), feature = "n_obs") ```