From 1441cc5e50f1e47531e8030757d1f8b1e0445129 Mon Sep 17 00:00:00 2001 From: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:01:59 +0100 Subject: [PATCH 1/3] map Vespa valutina types to quantity --- src/dwc_mapping.Rmd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dwc_mapping.Rmd b/src/dwc_mapping.Rmd index 9f8bcee..23e0cf5 100644 --- a/src/dwc_mapping.Rmd +++ b/src/dwc_mapping.Rmd @@ -150,7 +150,12 @@ input_data %<>% mutate(organism_quantity = case_when( waarneming_type == "Vastgesteld (in m²)" | waarneming_type == "Vastgesteld (aantal)" | - waarneming_type == "Secundair nest vastgesteld" ~ waarneming_kwantiteit, + waarneming_type == "Secundair nest vastgesteld" | + waarneming_type == "Secundair nest" | + waarneming_type == "Embryonest vastgesteld" | + waarneming_type == "Nest vastgesteld" | + waarneming_type == "Primair nest" | + waarneming_type == "Primair nest vastgesteld" ~ waarneming_kwantiteit, TRUE ~ "" )) ``` From 49e5ec3531af84f2a8594ce71325d8be94ed8655 Mon Sep 17 00:00:00 2001 From: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:23:01 +0100 Subject: [PATCH 2/3] add test so organismQuanityType always has an organismQuantity --- tests/test_dwc_occurrence.R | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_dwc_occurrence.R b/tests/test_dwc_occurrence.R index 861cae8..42f8ecf 100644 --- a/tests/test_dwc_occurrence.R +++ b/tests/test_dwc_occurrence.R @@ -86,6 +86,21 @@ testthat::test_that( testthat::expect_true(all(!is.na(organismQuantityType_values))) }) +testthat::test_that( + "an organsimQuantityType must have a corresponding organsimQuantity", + { + # there should be no cases where there is an organismQuantityType and no + # organismQuantity + testthat::expect_identical( + nrow(dplyr::filter( + dwc_occurrence, + !is.na(organismQuantityType) & is.na(organismQuantity) + )), + 0 + ) + } +) + testthat::test_that( "organismQuantityType is one of the predefined values if not NA", { values <- c("individual(s)", "square meter(s)", "nest") From 5144c032b8e1685b5549d9b878b25b2ba48133e6 Mon Sep 17 00:00:00 2001 From: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:46:37 +0100 Subject: [PATCH 3/3] increase strictness: identical not equal --- tests/test_dwc_occurrence.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_dwc_occurrence.R b/tests/test_dwc_occurrence.R index 42f8ecf..fa6cb08 100644 --- a/tests/test_dwc_occurrence.R +++ b/tests/test_dwc_occurrence.R @@ -96,7 +96,7 @@ testthat::test_that( dwc_occurrence, !is.na(organismQuantityType) & is.na(organismQuantity) )), - 0 + 0L ) } )