options(htmltools.dir.version = FALSE)
xaringanthemer::style_mono_accent(
  base_color = "#2f4174",
  inverse_header_color = "#FFFFFF"
)

What data do you need?

How do you get the data?


Installation

Current version can be installed from the GitHub repository:

install.packages("remotes")
remotes::install_github("special-uor/ageR")

To verify you are running the latest version, run the following command:

?ageR

class: inverse, center, middle

Demo


Example (Toy data)

File structure

ageR::file_structure(entity = "X", am = "bacon")

Input data

Core data

core <- data.frame(labID = paste0("X", sprintf("%03d", 1:5)),
                   age = c(50, 200, 1150, 2060, 4050),
                   error = c(10, 15, 5, 1, 70),
                   depth = c(5, 100, 230, 300, 450),
                   cc = 1)
knitr::kable(core)

Input data (2)

Sampling depths

sample_depths <- data.frame(id = 1:100,
                            depth = seq(0, 500, length.out = 100))
knitr::kable(head(sample_depths))

Input data (3)

(Optional) Hiatuses

hiatus <- data.frame(id = c(1, 2),
                     depth = c(50, 150))
knitr::kable(hiatus)

Input data (4)

ageR::create_input(data = list(sample_depths = sample_depths, 
                               core = core,
                               # Optional
                               hiatus = NULL,
                               not_used = NULL), 
                   wdir = "./", 
                   entity = "X",
                   am = "bacon")

Databases: RPD

conn <- dabr::open_conn_mysql("RPD-latest")
query <- paste0(
"SELECT entity_name,
       entity.ID_ENTITY as entity_id,
         lab_number AS labID,
       age_C14 AS age,
       error,
       avg_depth*100 AS depth,
       date_type,
       thickness
FROM date_info INNER JOIN entity
    ON date_info.ID_ENTITY = entity.ID_ENTITY
WHERE latitude >= 45")

rpd <- dabr::select(conn, query, quiet = TRUE)
nrow(rpd)

Databases: RPD (2)

`%>%` <- dplyr::`%>%`
rpd <- rpd %>%
  dplyr::filter(!is.na(age)) %>%
  dplyr::filter(!is.na(error)) %>%
  dplyr::filter(!is.na(depth)) %>%
  dplyr::mutate(error =  ifelse(error <= 0, 1, error)) %>%
  dplyr::arrange(depth) %>%
  dplyr::mutate(cc = ifelse(grepl("*carbon", date_type), 1, 0))

entities <- sort(unique(rpd$entity_name))
head(entities)

Databases: RPD (3)

test_entity <- "Burnt Knob core 1"
test_entity_id <- unique(rpd$entity_id[rpd$entity_name == test_entity])

# Extract sampling depths
query <- paste0("SELECT ID_SAMPLE AS id, sample_depth*100 AS depth
                 FROM sample
                 WHERE ID_ENTITY = ", test_entity_id)
sample_tb <- dabr::select(conn, query, quiet = TRUE)
sample_tb <- sample_tb %>%
  dplyr::filter(depth != -9999)

# Extract core data
my_core <- rpd[rpd$entity_name == test_entity, 
               c("labID", "age", "error", "depth", "cc")]

# Create input
ageR::create_input(data = list(core = my_core, 
                               sample_depths = sample_tb), 
                   wdir = "./", 
                   entity = test_entity)

Run Bacon

ageR::Bacon(wdir = "./", 
            entity = "X", 
            # Optional parameters
            cpus = 1,
            postbomb = 0,
            cc = 0,
            seed = NA,
            alt_depths = NULL,
            quiet = FALSE,
            acc_step = 5,
            acc_lower = NULL,
            acc_upper = NULL,
            thick_step = 5,
            thick_lower = NULL,
            thick_upper = NULL,
            dry_run = FALSE,
            ...)

More details: https://special-uor.github.io/ageR/reference/Bacon

Run Bacon: Dry-run

out <- ageR::Bacon(wdir = "./", entity = "X", dry_run = TRUE, quiet = TRUE)

Run Bacon: Mixed calibration curves

ccdir <- "./ccurves"
ageR::mix_curves(proportion = 0.5, 
                 cc1 = 1, 
                 cc = 3, 
                 name = "neotropics.14C", 
                 dirname = ccdir)
out <- ageR::Bacon(wdir = "./", 
                   entity = "X", 
                   cc4 = "neotropics.14C", 
                   ccdir = ccdir)

Wishlist (aka GitHub issues)

Create new "Issues" to request new features, report an error, etc.

https://github.com/special-uor/ageR/issues


class: center, middle

Thanks!

Slides created using the R package xaringan.

unlink("X", recursive = TRUE, force = TRUE)
unlink("ccurves", recursive = TRUE, force = TRUE)
unlink("Burnt Knob core 1", recursive = TRUE, force = TRUE)


special-uor/ageR documentation built on July 10, 2024, 10:08 p.m.