From 8916d1c035d979e19abafd41fb39b690f55be55b Mon Sep 17 00:00:00 2001 From: Ramiro Magno Date: Tue, 6 Aug 2024 16:35:27 +0100 Subject: [PATCH] Update online docs --- .Rbuildignore | 1 + DESCRIPTION | 5 +- README.Rmd | 68 ++--------- README.md | 123 ++------------------ _pkgdown.yml | 15 +++ vignettes/.gitignore | 2 + vignettes/articles/crosswalks.Rmd | 74 ++++++++++++ vignettes/articles/eunis-classification.Rmd | 52 +++++++++ 8 files changed, 169 insertions(+), 171 deletions(-) create mode 100644 vignettes/.gitignore create mode 100644 vignettes/articles/crosswalks.Rmd create mode 100644 vignettes/articles/eunis-classification.Rmd diff --git a/.Rbuildignore b/.Rbuildignore index ef3238b..4cc3922 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -10,3 +10,4 @@ ^pkgdown$ ^cran-comments\.md$ ^CRAN-SUBMISSION$ +^vignettes/articles$ diff --git a/DESCRIPTION b/DESCRIPTION index 0d405b5..b989325 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,8 +11,7 @@ Authors@R: c( role = "ctb", comment = c(ORCID = "0000-0001-6884-2886")), person("Pattern Institute", role = c("cph", "fnd")), - person("CCMAR", - role = "fnd") + person("CCMAR", role = "fnd") ) Description: The EUNIS habitat classification is a comprehensive pan-European system for habitat identification @@ -32,5 +31,5 @@ Depends: Roxygen: list(markdown = TRUE) URL: https://github.com/patterninstitute/eunis.habitats, https://www.pattern.institute/eunis.habitats/, http://www.pattern.institute/eunis.habitats/ BugReports: https://github.com/patterninstitute/eunis.habitats/issues -Config/Needs/website: patterninstitute/chic +Config/Needs/website: patterninstitute/chic, rmarkdown License: CC0 diff --git a/README.Rmd b/README.Rmd index 647c7b2..5f0d017 100644 --- a/README.Rmd +++ b/README.Rmd @@ -20,8 +20,10 @@ library(eunis.habitats) [![CRAN status](https://www.r-pkg.org/badges/version/eunis.habitats)](https://CRAN.R-project.org/package=eunis.habitats) -`{eunis.habitats}` is an R data package that provides the [EUNIS Habitat -Classification](https://www.eea.europa.eu/data-and-maps/data/eunis-habitat-classification-1) in tidy format. +`{eunis.habitats}` is an R data package that provides the EUNIS habitat +classification in tidy format. + +Use the helper `crosswalk()` to map habitat codes across classification systems. ## Installation @@ -33,67 +35,19 @@ install.packages("eunis.habitats") ## EUNIS classifications -There are four EUNIS classifications included in the one single data set `eunis_habitats`, namely: +The data set `eunis_habitats` provides the four EUNIS classifications: 1. EUNIS classification from 2007, revised in 2012. 2. EUNIS marine classification from 2019 3. EUNIS marine classification from 2022 4. EUNIS terrestrial classification from 2021 -For example, to access the marine habitats classified according to EUNIS revision of 2022: - -```{r} -subset(eunis_habitats, classification == "EUNIS_M_2022") -``` - -Check the documentation for more details: `?eunis_habitats`. - -## Crosswalks (mapping of habitat codes) - -From EUNIS 2012 to EUNIS Marine 2022: - -```{r} -crosswalk( - code = c("A3.4", "A3.5"), - from = "EUNIS_2012", - to = "EUNIS_M_2022", - unnest = TRUE -) -``` - -From EUNIS Marine 2019 to EUNIS 2012: +See `vignette("eunis-classification")` to learn more. In addition, we also +provide a helper for converting habitat codes across: -```{r} -crosswalk( -code = c("MH152", "MH2331"), -from = "EUNIS_M_2019", -to = "EUNIS_2012", -unnest = TRUE -) -``` - -From EUNIS Marine 2022 to the European Red List of Habitats: - -```{r} -crosswalk( -code = c("MH152", "MH2331", "MA146", "MD55"), -from = "EUNIS_M_2022", -to = "RL", -unnest = TRUE -) -``` - -From EUNIS Marine 2019 to Habitats Directive Annex I: - -```{r} -crosswalk( -code = c("M", "MA1", "MA11", "MA12"), -from = "EUNIS_M_2019", -to = "Annex_I", unnest = TRUE -) -``` +- EUNIS habitat classifications +- European Red List of Habitats +- Habitats Directive Annex I -## Original data source +See `vignette("crosswalks")` for more details. -The original data is by [EUNIS Habitat -Classification](https://www.eea.europa.eu/data-and-maps/data/eunis-habitat-classification-1). diff --git a/README.md b/README.md index 6b7e136..c040713 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,11 @@ status](https://www.r-pkg.org/badges/version/eunis.habitats)](https://CRAN.R-project.org/package=eunis.habitats) -`{eunis.habitats}` is an R data package that provides the [EUNIS Habitat -Classification](https://www.eea.europa.eu/data-and-maps/data/eunis-habitat-classification-1) -in tidy format. +`{eunis.habitats}` is an R data package that provides the EUNIS habitat +classification in tidy format. + +Use the helper `crosswalk()` to map habitat codes across classification +systems. ## Installation @@ -23,119 +25,18 @@ install.packages("eunis.habitats") ## EUNIS classifications -There are four EUNIS classifications included in the one single data set -`eunis_habitats`, namely: +The data set `eunis_habitats` provides the four EUNIS classifications: 1. EUNIS classification from 2007, revised in 2012. 2. EUNIS marine classification from 2019 3. EUNIS marine classification from 2022 4. EUNIS terrestrial classification from 2021 -For example, to access the marine habitats classified according to EUNIS -revision of 2022: - -``` r -subset(eunis_habitats, classification == "EUNIS_M_2022") -#> # A tibble: 1,942 × 8 -#> classification section version group level code name description -#> -#> 1 EUNIS_M_2022 marine 2022 benthic 1 M Marine bent… "Marine be… -#> 2 EUNIS_M_2022 marine 2022 benthic 2 MA1 Littoral ro… "Littoral … -#> 3 EUNIS_M_2022 marine 2022 benthic 3 MA11 Arctic litt… "Arctic li… -#> 4 EUNIS_M_2022 marine 2022 benthic 3 MA12 Atlantic li… "Atlantic … -#> 5 EUNIS_M_2022 marine 2022 benthic 4 MA121 Lichens or … "Lichen co… -#> 6 EUNIS_M_2022 marine 2022 benthic 5 MA1211 Yellow and … "Vertical … -#> 7 EUNIS_M_2022 marine 2022 benthic 5 MA1212 Prasiola st… "Exposed t… -#> 8 EUNIS_M_2022 marine 2022 benthic 5 MA1213 Verrucaria … "Bedrock o… -#> 9 EUNIS_M_2022 marine 2022 benthic 6 MA12131 Verrucaria … "The litto… -#> 10 EUNIS_M_2022 marine 2022 benthic 6 MA12132 Verrucaria … "Upper lit… -#> # ℹ 1,932 more rows -``` - -Check the documentation for more details: `?eunis_habitats`. - -## Crosswalks (mapping of habitat codes) - -From EUNIS 2012 to EUNIS Marine 2022: - -``` r -crosswalk( - code = c("A3.4", "A3.5"), - from = "EUNIS_2012", - to = "EUNIS_M_2022", - unnest = TRUE -) -#> # A tibble: 64 × 2 -#> eunis_2012_code eunis_m_2022_code -#> -#> 1 A3.4 MA133 -#> 2 A3.4 MA134 -#> 3 A3.4 MA135 -#> 4 A3.4 MA136 -#> 5 A3.4 MA137 -#> 6 A3.4 MB13 -#> 7 A3.4 MB131 -#> 8 A3.4 MB1311 -#> 9 A3.4 MB1312 -#> 10 A3.4 MB1313 -#> # ℹ 54 more rows -``` - -From EUNIS Marine 2019 to EUNIS 2012: - -``` r -crosswalk( -code = c("MH152", "MH2331"), -from = "EUNIS_M_2019", -to = "EUNIS_2012", -unnest = TRUE -) -#> # A tibble: 2 × 2 -#> eunis_m_2019_code eunis_2012_code -#> -#> 1 MH152 A7.12 -#> 2 MH2331 A7.231 -``` - -From EUNIS Marine 2022 to the European Red List of Habitats: - -``` r -crosswalk( -code = c("MH152", "MH2331", "MA146", "MD55"), -from = "EUNIS_M_2022", -to = "RL", -unnest = TRUE -) -#> # A tibble: 4 × 2 -#> eunis_m_2022_code rl_code -#> -#> 1 MH152 -#> 2 MH2331 -#> 3 MA146 A1.1xx -#> 4 MD55 A5.27 -``` - -From EUNIS Marine 2019 to Habitats Directive Annex I: - -``` r -crosswalk( -code = c("M", "MA1", "MA11", "MA12"), -from = "EUNIS_M_2019", -to = "Annex_I", unnest = TRUE -) -#> # A tibble: 7 × 2 -#> eunis_m_2019_code annex_i_code -#> -#> 1 M -#> 2 MA1 -#> 3 MA11 -#> 4 MA12 8330 -#> 5 MA12 1160 -#> 6 MA12 1170 -#> 7 MA12 1130 -``` +See `vignette("eunis-classification")` to learn more. In addition, we +also provide a helper for converting habitat codes across: -## Original data source +- EUNIS habitat classifications +- European Red List of Habitats +- Habitats Directive Annex I -The original data is by [EUNIS Habitat -Classification](https://www.eea.europa.eu/data-and-maps/data/eunis-habitat-classification-1). +See `vignette("crosswalks")` for more details. diff --git a/_pkgdown.yml b/_pkgdown.yml index 55531be..2c5a864 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -6,6 +6,9 @@ template: home: title: EUNIS Habitat Classification description: EUNIS Habitats and crosswalks + links: + - text: EUNIS habitat classification + href: https://www.eea.europa.eu/data-and-maps/data/eunis-habitat-classification-1/ authors: Ramiro Magno: @@ -29,3 +32,15 @@ reference: desc: "Convert habitat codes across EUNIS, European Red List and Habitats Directive Annex I" contents: - crosswalk + +navbar: + structure: + left: [eunis, crosswalks, reference, news] + right: [search, github] + components: + eunis: + text: EUNIS Classification + href: articles/eunis-classification.html + crosswalks: + text: Crosswalks + href: articles/crosswalks.html diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..097b241 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/articles/crosswalks.Rmd b/vignettes/articles/crosswalks.Rmd new file mode 100644 index 0000000..1212a00 --- /dev/null +++ b/vignettes/articles/crosswalks.Rmd @@ -0,0 +1,74 @@ +--- +title: "Crosswalk of Habitat Codes" +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +library(eunis.habitats) +``` + +The function `crosswalk()` provides an easy mapping from habitat codes in +one classification system to another. + +### From EUNIS 2012 to EUNIS Marine 2022 + +```{r} +crosswalk( + code = c("A3.4", "A3.5"), + from = "EUNIS_2012", + to = "EUNIS_M_2022", + unnest = TRUE +) +``` + +### From EUNIS Marine 2019 to EUNIS 2012 + +```{r} +crosswalk( + code = c("MH152", "MH2331"), + from = "EUNIS_M_2019", + to = "EUNIS_2012", + unnest = TRUE +) +``` + +### From EUNIS Marine 2022 to the European Red List of Habitats + +```{r} +crosswalk( + code = c("MH152", "MH2331", "MA146", "MD55"), + from = "EUNIS_M_2022", + to = "RL", + unnest = TRUE +) +``` + +### One to many mappings + +Note that some mappings are one to many, e.g. `"MA12"` in EUNIS Marine 2019 maps +to the following _Habitats Directive Annex I_ habitat codes: `"8330"`, `"1160"`, +`"1170"` and `"1130"`. That is why, by default, the _to_ column is a +list-column. + +```{r} +crosswalk( + code = c("M", "MA1", "MA11", "MA12"), + from = "EUNIS_M_2019", + to = "Annex_I" +) +``` + +You need to use `unnest = TRUE` to flatten out the table of mappings and +convert the _to_ list-column to a character vector column. + +```{r} +crosswalk( + code = c("M", "MA1", "MA11", "MA12"), + from = "EUNIS_M_2019", + to = "Annex_I", + unnest = TRUE +) +``` diff --git a/vignettes/articles/eunis-classification.Rmd b/vignettes/articles/eunis-classification.Rmd new file mode 100644 index 0000000..cea2a18 --- /dev/null +++ b/vignettes/articles/eunis-classification.Rmd @@ -0,0 +1,52 @@ +--- +title: "EUNIS Classification Systems" +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +library(eunis.habitats) +library(dplyr) +``` + +EUNIS habitats are provided as the tidy data set `eunis_habitats`, each row +corresponding to a habitat at varying levels of description. + +```{r} +eunis_habitats +``` + +## EUNIS four classifications + +The `eunis_habitats` data set comprises four habitat classifications: + +1. EUNIS classification from 2007, revised in 2012. +2. EUNIS marine classification from 2019. +3. EUNIS marine classification from 2022. +4. EUNIS terrestrial classification from 2021. + +The column `classification` distinguishes which is which: + +```{r} +dplyr::distinct(eunis_habitats, classification) +``` + +For example, to access the level 1 marine habitats classified +according to EUNIS revision of 2022 (`"EUNIS_M_2022"`): + +```{r} +dplyr::filter(eunis_habitats, classification == "EUNIS_M_2022", level == 1L) +``` + +And to list ice habitats (level 2): + +```{r} +dplyr::filter(eunis_habitats, + classification == "EUNIS_M_2022", + group == "ice", + level == 2L) |> + dplyr::select("code", "name") +``` +