Skip to content

Commit

Permalink
Add shub1_c14
Browse files Browse the repository at this point in the history
As a less intensive example of aggregation. Moved from stratigraphr.
  • Loading branch information
joeroe committed Oct 17, 2024
1 parent e955571 commit 39e3687
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* `c14_age()` for calculating a radiocarbon age from fraction modern.
* `c14_f14c()` for reverse-calculating fraction modern from a radiocarbon age.
* Decay constants `c14_decay_libby` and `c14_decay_cambridge`.
* Added example datasets `ppnd` and `shub1_c14`

# c14 0.0.0

Expand Down
4 changes: 2 additions & 2 deletions R/cal_aggregate.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#' @export
#'
#' @examples
#' ppnd_cal <- c14_calibrate(ppnd$cra, ppnd$error)
#' cal_sum(ppnd_cal)
#' shub1_cal <- c14_calibrate(shub1_c14$c14_age, shub1_c14$c14_error)
#' cal_sum(shub1_cal)
cal_sum <- function(x, range = cal_age_common(x), ...) {
# TODO: ensure x and range have the same era - or is this a job for cal validation?
x <- cal_interpolate(x, range)
Expand Down
30 changes: 30 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,36 @@
#' @source \url{https://www.exoriente.org/associated_projects/ppnd.php} (Retrieved 2018-04-02)
"ppnd"

# shub1_radiocarbon -------------------------------------------------------
#' Radiocarbon dates from Shubayqa 1
#'
#' Radiocarbon dates from Shubayqa 1, an Epipalaeolithic site in eastern Jordan,
#' from \insertCite{Richter2017;textual}{c14}.
#'
#' @format A data frame with 27 rows and 8 variables:
#' \describe{
#' \item{lab_id}{character; standardised lab code uniquely identifying the dated sample.}
#' \item{context}{integer; schematic context number the sample was found in (see details).}
#' \item{phase}{character; phase the sample was assigned to.}
#' \item{sample}{character; description of the sample context, including its real context number.}
#' \item{material}{character; description of the sample material.}
#' \item{c14_age}{integer; conventional radiocarbon age of the sample in years cal BP.}
#' \item{c14_error}{integer; standard error associated with the radiocarbon measurement in ± years cal BP.}
#' \item{outlier}{logical; whether the sample is considered an outlier.}
#' }
#'
#' @details
#'
#' `context` refers to the schematic stratigraphy included in [stratigraphr::shub1];
#' the real context number is described in `sample`.
#'
#' @source \insertCite{Richter2017;textual}{c14}
#'
#' @references
#' \insertAllCited{}
"shub1_c14"


#' Radiocarbon laboratories
#'
#' @description
Expand Down
Binary file added data-raw/41598_2017_17096_MOESM2_ESM.xlsx
Binary file not shown.
75 changes: 75 additions & 0 deletions data-raw/shub1_c14.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# shub1_c14.R
# Prepare shub1_c14 dataset – radiocarbon dates from Shubayqa 1 (Richter et al.
# 2017, ESM 2, "Radiocarbon Dates")
#
# Citation: Richter, T., Arranz-Otaegui, A., Yeomans, L. et al. High Resolution
# AMS Dates from Shubayqa 1, northeast Jordan Reveal Complex Origins of Late
# Epipalaeolithic Natufian in the Levant. Sci Rep 7, 17025 (2017).
# https://doi.org/10.1038/s41598-017-17096-5

shub1_c14 <- readxl::read_xlsx("data-raw/41598_2017_17096_MOESM2_ESM.xlsx")

# Discard unwanted columns and normalise the names of the rest
shub1_c14 <- dplyr::select(shub1_c14,
lab_id = `Laboratory Code`,
phase = `Archaeological Phase`,
sample = `Sample Context ID`,
material = `Sample material`,
age = `C-14 Age ±1σ year BP`
)

# Fill missing phases
shub1_c14 <- tidyr::fill(shub1_c14, phase)

# Discard non-data rows
shub1_c14 <- tidyr::drop_na(shub1_c14, lab_id)

# Normalise lab IDs
shub1_c14 <- dplyr::mutate(shub1_c14,
lab_id = stringr::str_remove(lab_id, "R_Date "))

# Add an outlier column (marked with a "*" next to the lab ID in the original data)
shub1_c14 <- dplyr::mutate(shub1_c14,
outlier = stringr::str_detect(lab_id, stringr::coll("*")),
lab_id = stringr::str_remove(lab_id, stringr::coll("*")))

# Separate age and error in radiocarbon date
shub1_c14 <- tidyr::separate(shub1_c14, age, c("c14_age", "c14_error"), " ±")
shub1_c14$c14_age <- as.integer(shub1_c14$c14_age)
shub1_c14$c14_error <- as.integer(shub1_c14$c14_error)

# Add schematic context numbers to match "shub1" dataset from stratigraphr
shub1_c14 <- dplyr::mutate(shub1_c14,
context = dplyr::recode(lab_id,
`RTD-7951` = 23,
`Beta-112146` = 24,
`RTD-7317` = 26,
`RTD-7318` = 27,
`RTD-7948` = 24,
`RTD-7947` = 22,
`RTD-7313` = 22,
`RTD-7311` = 22,
`RTD-7312` = 22,
`RTD-7314` = 22,
`RTD-7316` = 22,
`RTD-7315` = 22,
`RTK-6818` = 14,
`RTK-6820` = 14,
`RTK-6821` = 16,
`RTK-6822` = 16,
`RTK-6823` = 16,
`RTK-6813` = 12,
`RTK-6816` = 12,
`RTK-6819` = 5,
`RTK-6812` = 3,
`RTK-6817` = 2,
`RTD-8904` = 1,
`RTK-6814` = 1,
`RTD-8902` = 1,
`RTD-8903` = 1,
`RTK-6815` = 1))
shub1_c14 <- dplyr::relocate(shub1_c14, context, .after = lab_id)
shub1_c14$context <- as.integer(shub1_c14$context)

# Export
usethis::use_data(shub1_c14, overwrite = TRUE)
Binary file added data/shub1_c14.rda
Binary file not shown.
16 changes: 16 additions & 0 deletions inst/REFERENCES.bib
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,22 @@ @ARTICLE{Reimer2020
doi = "10.1017/RDC.2020.41"
}

@ARTICLE{Richter2017,
title = "High Resolution {AMS} Dates from Shubayqa 1, northeast Jordan
Reveal Complex Origins of Late Epipalaeolithic Natufian in the
Levant",
author = "Richter, Tobias and Arranz-Otaegui, Amaia and Yeomans, Lisa and
Boaretto, Elisabetta",
journal = "Scientific reports",
volume = 7,
number = 1,
pages = "17025",
month = dec,
year = 2017,
issn = "2045-2322",
doi = "10.1038/s41598-017-17096-5"
}

@TECHREPORT{Stenstrom2011,
title = "A guide to radiocarbon units and calculations",
author = "Stenstr{\"o}m, Kristina Eriksson and Skog, G{\"o}ran and
Expand Down
4 changes: 2 additions & 2 deletions man/cal_sum.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions man/shub1_c14.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 39e3687

Please sign in to comment.