knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

special.epd: SPECIAL Research Group's Version of the European Pollen Database (EPD)

r badger::badge_devel("special-uor/special.epd", "yellow") r badger::badge_github_actions("special-uor/special.epd") r badger::badge_cran_release("special.epd", "black")

The goal of special.epd is to provide access to the SPECIAL Research group's version of the European Pollen Database (EPD).

Installation

You can(not) install the released version of special.epd from CRAN with:

install.packages("special.epd")

And the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("special-uor/special.epd", "dev")

Example

Load tables to working environment

data("entity", package = "special.epd")
data("date_info", package = "special.epd")
data("sample", package = "special.epd")
data("age_model", package = "special.epd")
data("pollen_count", package = "special.epd")

Create a snapshot of entities

The function special.epd::snapshot takes few different parameters and based on the first one, x, it returns a variety of snapshots.

This function returns a list with 5 components:

All these data frames can be linked to the sample table using the column called ID_SAMPLE.

:warning: NOTE: the output is returned "invisibly", so you should assign the output of the function to a variable.

output <- special.epd::snapshot(...)
output$entity
output$date_info
output$sample
output$pollen_count$clean
output$pollen_count$intermediate
output$pollen_count$intermediate
Using the entity_name
special.epd::snapshot("MBA3")
Using the site_name
special.epd::snapshot("Abant Golu", use_site_name = TRUE)
Using the ID_ENTITY
special.epd::snapshot(2)
Using the ID_SITE
special.epd::snapshot(3, use_id_site = TRUE)
Extracting multiple records at once
special.epd::snapshot(1:10)
Extracting all the records at once

This will run very slow, so if only few entities are required, it would be better to indicate which, based on the previous examples.

out <- special.epd::snapshot()

Export data as individual CSV files

The function special.epd::write_csvs takes to parameters:

Without a path
`%>%` <- special.epd::`%>%`
special.epd::snapshot("MBA3") %>%
  special.epd::write_csvs(prefix = "MBA3")
Output
paths <- list.files(pattern = "MBA3", full.names = TRUE)
tree <- data.tree::as.Node(data.frame(pathString = paths))
data.tree::SetGraphStyle(tree, rankdir = "TB")
data.tree::SetNodeStyle(tree,
                        style = "filled,rounded",
                        shape = "box")
print(tree)
Including a path
`%>%` <- special.epd::`%>%`
special.epd::snapshot("MBA3") %>%
  special.epd::write_csvs(prefix = "/special.uor/epd/MBA3")
Output
paths <- list.files(pattern = "MBA3", full.names = TRUE) %>%
  stringr::str_replace_all("./", "/special.uor/epd/")
tree <- data.tree::as.Node(data.frame(pathString = paths))
data.tree::SetGraphStyle(tree, rankdir = "TB")
data.tree::SetNodeStyle(tree,
                        style = "filled,rounded",
                        shape = "box")
print(tree)
paths <- list.files(pattern = "MBA3", full.names = TRUE)
unlink(paths)

Spatial distribution of the entities

`%>%` <- special.epd::`%>%`
special.epd::entity %>%
  smpds::plot_climate(var = "elevation", units = "m ASL", 
                      ylim = c(25, 85),
                      xlim = c(-30, 170))

Extract Potential Natural Vegetation (PNV)

Using the package smpds [https://github.com/special-uor/smpds] we can extract the PNV for each entity and create a plot:

`%>%` <- special.epd::`%>%`
special.epd_pnv <- special.epd::entity %>%
  smpds::extract_biome()

# For a quicker execution
special.epd_pnv <- special.epd::entity %>%
  smpds::parallel_extract_biome(cpus = 4)

# Plot the PNV
special.epd_pnv %>%
  smpds::plot_biome(ylim = c(25, 85),
                    xlim = c(-30, 170))
`%>%` <- special.epd::`%>%`
special.epd_pnv <- special.epd::entity %>%
  smpds::parallel_extract_biome(cpus = 12)

# Plot the PNV
special.epd_pnv %>%
  smpds::plot_biome(ylim = c(25, 85),
                    xlim = c(-30, 170))

Summary of the database

`%>%` <- special.epd::`%>%`
special_epd_summary <- special.epd::db_summary()
tibble::tibble(
    `# Entities` = nrow(special_epd_summary),
    `with Dates` = sum(special_epd_summary$has_DATES, na.rm = TRUE),
    `with Age models (using IntCal20)` = sum(special_epd_summary$has_AM, na.rm = TRUE),
    `with Pollen counts` = sum(special_epd_summary$has_COUNTS, na.rm = TRUE)
  ) %>%
  knitr::kable()


special-uor/special.epd documentation built on April 10, 2022, 11:06 a.m.