Skip to content

Commit

Permalink
Update online docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiromagno committed Aug 6, 2024
1 parent 5dae5e6 commit 8916d1c
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 171 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
^pkgdown$
^cran-comments\.md$
^CRAN-SUBMISSION$
^vignettes/articles$
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
68 changes: 11 additions & 57 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<!-- badges: end -->

`{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

Expand All @@ -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).
123 changes: 12 additions & 111 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
status](https://www.r-pkg.org/badges/version/eunis.habitats)](https://CRAN.R-project.org/package=eunis.habitats)
<!-- badges: end -->

`{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

Expand All @@ -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
#> <chr> <chr> <chr> <chr> <int> <chr> <chr> <chr>
#> 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
#> <chr> <chr>
#> 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
#> <chr> <chr>
#> 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
#> <chr> <chr>
#> 1 MH152 <NA>
#> 2 MH2331 <NA>
#> 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
#> <chr> <chr>
#> 1 M <NA>
#> 2 MA1 <NA>
#> 3 MA11 <NA>
#> 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.
15 changes: 15 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
2 changes: 2 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
*.R
74 changes: 74 additions & 0 deletions vignettes/articles/crosswalks.Rmd
Original file line number Diff line number Diff line change
@@ -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
)
```
Loading

0 comments on commit 8916d1c

Please sign in to comment.