Create a snapshot of the data linked to entities. Including metadata, dates, samples, age models and pollen counts.

snapshot(x, ...)

# S3 method for MariaDBConnection
snapshot(x, ..., ID_ENTITY, ID_SITE, entity_name, site_name, quiet = TRUE)

# S3 method for character
snapshot(x, ..., use_site_name = FALSE)

# S3 method for numeric
snapshot(x, ..., use_id_site = FALSE)

# S3 method for tbl_df
snapshot(x, ...)

# S3 method for tbl
snapshot(x, ...)

# S3 method for data.frame
snapshot(x, ...)

# S3 method for default
snapshot(x, ...)

Arguments

x

This object accepts different classes. If the given object is a database connection, then extracts data from the database using the ID_SITE, ID_ENTITY or entity_name (these should be provided after the connection object). Alternatively, if the given object is a vector, then it will retrieve the records from an internal snapshot of the database, included in this package.

...

Optional parameters.

ID_ENTITY

Optional, if ID_SITE, entity_name or site_name are provided.

ID_SITE

Optional, if ID_ENTITY, entity_name or site_name are provided.

entity_name

Optional, if ID_SITE, ID_ENTITY or site_name are provided.

site_name

Optional, if ID_SITE, ID_ENTITY or entity_name are provided.

quiet

Boolean flag to indicate if queries should be displayed.

use_site_name

Boolean flag to indicate whether to search using entity_name (default) or site_name, using the values in x.

use_id_site

Boolean flag to indicate whether to search using ID_ENTITY (default) or ID_SITE, using the values in x.

Value

List with the individual tables.

Examples


if (FALSE) {
conn <- dabr::open_conn_mysql(dbname = "SPECIAL-EPD",
                              password = rstudioapi::askForPassword())
# Using the entity name
snp1 <- special.epd::snapshot(conn, entity_name = "MBA3")
snp1

# Using the site name
snp2 <- special.epd::snapshot(conn, site_name = "Aammiq")
snp2

# Using the ID_ENTITY
snp3 <- special.epd::snapshot(conn, ID_ENTITY = 1)
snp3

# Using the ID_SITE
snp4 <- special.epd::snapshot(conn, ID_SITE = 2)
snp4
}
# Using the entity name
snp1 <- special.epd::snapshot("MBA3")
snp1
#> # A tibble: 1 × 8
#>   ID_SITE ID_ENTITY site_name    entity_name dates samples age_model
#>     <int>     <int> <chr>        <chr>       <int>   <int>     <int>
#> 1       1         1 Aalkistensee MBA3            7      57        57
#> # … with 1 more variable: pollen_counts <tibble[,3]>

# Using the site name
snp2 <- special.epd::snapshot("Aammiq", use_site_name = TRUE)
snp2
#> # A tibble: 1 × 8
#>   ID_SITE ID_ENTITY site_name entity_name dates samples age_model
#>     <int>     <int> <chr>     <chr>       <int>   <int>     <int>
#> 1       2         2 Aammiq    AMMIQ           4      96        96
#> # … with 1 more variable: pollen_counts <tibble[,3]>
# Using the ID_ENTITY
snp1 <- special.epd::snapshot(1)
snp1
#> # A tibble: 1 × 8
#>   ID_SITE ID_ENTITY site_name    entity_name dates samples age_model
#>     <int>     <int> <chr>        <chr>       <int>   <int>     <int>
#> 1       1         1 Aalkistensee MBA3            7      57        57
#> # … with 1 more variable: pollen_counts <tibble[,3]>

# Using the ID_SITE
snp2 <- special.epd::snapshot(2, use_id_site = TRUE)
snp2
#> # A tibble: 1 × 8
#>   ID_SITE ID_ENTITY site_name entity_name dates samples age_model
#>     <int>     <int> <chr>     <chr>       <int>   <int>     <int>
#> 1       2         2 Aammiq    AMMIQ           4      96        96
#> # … with 1 more variable: pollen_counts <tibble[,3]>
# Using the entity table
`%>%` <- magrittr::`%>%`
snp1 <- special.epd::entity %>%
  dplyr::slice(1) %>%
  special.epd::snapshot("MBA3")
snp1
#> # A tibble: 1 × 8
#>   ID_SITE ID_ENTITY site_name    entity_name dates samples age_model
#>     <int>     <int> <chr>        <chr>       <int>   <int>     <int>
#> 1       1         1 Aalkistensee MBA3            7      57        57
#> # … with 1 more variable: pollen_counts <tibble[,3]>

# Using a custom data frame (`tibble` object) with site names
snp2 <- tibble::tibble(
    site_name = c("Lingreville", "Machova")
  ) %>%
  special.epd::snapshot()
snp2
#> # A tibble: 5 × 8
#>   ID_SITE ID_ENTITY site_name   entity_name dates samples age_model
#>     <int>     <int> <chr>       <chr>       <int>   <int>     <int>
#> 1     810       916 Lingreville BRICQRUE        2      22        22
#> 2     810       917 Lingreville LINGR2C1        1      59         0
#> 3     810       918 Lingreville LINGR2C2        1      12         0
#> 4     810       919 Lingreville LINGREV4        1      29         0
#> 5     876       986 Machova     MACHOVA         1      21        21
#> # … with 1 more variable: pollen_counts <tibble[,3]>