| Title: | Interface to 'OxCal' Radiocarbon Calibration |
|---|---|
| Description: | A set of tools that enables using 'OxCal' from within R. 'OxCal' (<https://c14.arch.ox.ac.uk/oxcal.html>) is a standard archaeological tool intended to provide 14C calibration and analysis of archaeological and environmental chronological information. 'OxcAAR' allows simple calibration with 'Oxcal' and plotting of the results as well as the execution of sophisticated ('OxCal') code and the import of the results of bulk analysis and complex Bayesian sequential calibration. |
| Authors: | Hinz Martin [aut, cre], Clemens Schmid [aut], Daniel Knitter [aut], Carolin Tietze [aut] |
| Maintainer: | Hinz Martin <[email protected]> |
| License: | GPL-2 | file LICENSE |
| Version: | 1.1.2 |
| Built: | 2026-05-12 08:33:40 UTC |
| Source: | https://github.com/isaakiel/oxcaar |
Boundary returns the OxCal code for a Boundary. For details concerning the Oxcal simulation please consult the help page of Oxcal.
Boundary(names = "")Boundary(names = "")
names |
a optional vector of names for the resulting boundary. If missing or empty, an unnamed boundary is returned. |
a string containing the respective Oxcal code
Draws the calibration curve (with 1-sigma envelope) and overlays one or more calibrated dates as points and/or error bars (uncalibrated and calibrated ranges).
calcurve_plot( x, dates_sigma_ranges = c("two_sigma", "one_sigma", "three_sigma"), uncal_range = TRUE, cal_range = TRUE )calcurve_plot( x, dates_sigma_ranges = c("two_sigma", "one_sigma", "three_sigma"), uncal_range = TRUE, cal_range = TRUE )
x |
An object of class |
dates_sigma_ranges |
Character. The sigma range used for the calibrated error bars.
One of |
uncal_range |
Logical. If |
cal_range |
Logical. If |
NULL (called for its side effect: base graphics plot).
Takes an Oxcal Script, hands it over to oxcal and receives the output that is read from the output file
executeOxcalScript(oxcal_script, file = NULL)executeOxcalScript(oxcal_script, file = NULL)
oxcal_script |
A string containing the Oxcal commands that should be processed. |
file |
A string naming a file for writing. Elements of the path other than the last will be created if needed. If 'NULL' (the default), a temporary file will be used. |
The path to the js output file
Martin Hinz
Format an oxcAARCalibratedDate
## S3 method for class 'oxcAARCalibratedDate' format(x, ...)## S3 method for class 'oxcAARCalibratedDate' format(x, ...)
x |
|
... |
Unused (kept for S3 consistency). |
A character string (invisibly).
queries values from date objects
get_bp(x) ## Default S3 method: get_bp(x) ## S3 method for class 'oxcAARCalibratedDate' get_bp(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_bp(x)get_bp(x) ## Default S3 method: get_bp(x) ## S3 method for class 'oxcAARCalibratedDate' get_bp(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_bp(x)
x |
an object of class oxcAARCalibratedDate or oxcAARCalibratedDatesList |
an integer or a numeric vector
Other getter functions:
get_cal_curve(),
get_name(),
get_posterior_probabilities(),
get_posterior_sigma_ranges(),
get_raw_probabilities(),
get_sigma_ranges(),
get_std()
## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_bp(x) y <- oxcalCalibrate(5000, 20)[[1]] get_bp(y) ## End(Not run)## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_bp(x) y <- oxcalCalibrate(5000, 20)[[1]] get_bp(y) ## End(Not run)
queries values from date objects
get_cal_curve(x) ## Default S3 method: get_cal_curve(x) ## S3 method for class 'oxcAARCalibratedDate' get_cal_curve(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_cal_curve(x)get_cal_curve(x) ## Default S3 method: get_cal_curve(x) ## S3 method for class 'oxcAARCalibratedDate' get_cal_curve(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_cal_curve(x)
x |
an object of class oxcAARCalibratedDate or oxcAARCalibratedDatesList |
a string or a character vector
Other getter functions:
get_bp(),
get_name(),
get_posterior_probabilities(),
get_posterior_sigma_ranges(),
get_raw_probabilities(),
get_sigma_ranges(),
get_std()
## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_cal_curve(x) y <- oxcalCalibrate(5000, 20)[[1]] get_cal_curve(y) ## End(Not run)## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_cal_curve(x) y <- oxcalCalibrate(5000, 20)[[1]] get_cal_curve(y) ## End(Not run)
queries values from date objects
get_name(x) ## Default S3 method: get_name(x) ## S3 method for class 'oxcAARCalibratedDate' get_name(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_name(x)get_name(x) ## Default S3 method: get_name(x) ## S3 method for class 'oxcAARCalibratedDate' get_name(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_name(x)
x |
an object of class oxcAARCalibratedDate or oxcAARCalibratedDatesList |
a string or a character vector
Other getter functions:
get_bp(),
get_cal_curve(),
get_posterior_probabilities(),
get_posterior_sigma_ranges(),
get_raw_probabilities(),
get_sigma_ranges(),
get_std()
## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_name(x) y <- oxcalCalibrate(5000, 20)[[1]] get_name(y) ## End(Not run)## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_name(x) y <- oxcalCalibrate(5000, 20)[[1]] get_name(y) ## End(Not run)
queries values from date objects
get_posterior_probabilities(x) ## Default S3 method: get_posterior_probabilities(x) ## S3 method for class 'oxcAARCalibratedDate' get_posterior_probabilities(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_posterior_probabilities(x)get_posterior_probabilities(x) ## Default S3 method: get_posterior_probabilities(x) ## S3 method for class 'oxcAARCalibratedDate' get_posterior_probabilities(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_posterior_probabilities(x)
x |
an object of class oxcAARCalibratedDate or oxcAARCalibratedDatesList |
a list of three data.frames or a list of those lists
Other getter functions:
get_bp(),
get_cal_curve(),
get_name(),
get_posterior_sigma_ranges(),
get_raw_probabilities(),
get_sigma_ranges(),
get_std()
queries values from date objects
get_posterior_sigma_ranges(x) ## Default S3 method: get_posterior_sigma_ranges(x) ## S3 method for class 'oxcAARCalibratedDate' get_posterior_sigma_ranges(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_posterior_sigma_ranges(x)get_posterior_sigma_ranges(x) ## Default S3 method: get_posterior_sigma_ranges(x) ## S3 method for class 'oxcAARCalibratedDate' get_posterior_sigma_ranges(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_posterior_sigma_ranges(x)
x |
an object of class oxcAARCalibratedDate or oxcAARCalibratedDatesList |
a list of three data.frames or a list of those lists
Other getter functions:
get_bp(),
get_cal_curve(),
get_name(),
get_posterior_probabilities(),
get_raw_probabilities(),
get_sigma_ranges(),
get_std()
queries values from date objects
get_raw_probabilities(x) ## Default S3 method: get_raw_probabilities(x) ## S3 method for class 'oxcAARCalibratedDate' get_raw_probabilities(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_raw_probabilities(x)get_raw_probabilities(x) ## Default S3 method: get_raw_probabilities(x) ## S3 method for class 'oxcAARCalibratedDate' get_raw_probabilities(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_raw_probabilities(x)
x |
an object of class oxcAARCalibratedDate or oxcAARCalibratedDatesList |
a data.frame or a list of data.frames
Other getter functions:
get_bp(),
get_cal_curve(),
get_name(),
get_posterior_probabilities(),
get_posterior_sigma_ranges(),
get_sigma_ranges(),
get_std()
## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_raw_probabilities(x) y <- oxcalCalibrate(5000, 20)[[1]] get_raw_probabilities(y) ## End(Not run)## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_raw_probabilities(x) y <- oxcalCalibrate(5000, 20)[[1]] get_raw_probabilities(y) ## End(Not run)
queries values from date objects
get_sigma_ranges(x) ## Default S3 method: get_sigma_ranges(x) ## S3 method for class 'oxcAARCalibratedDate' get_sigma_ranges(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_sigma_ranges(x)get_sigma_ranges(x) ## Default S3 method: get_sigma_ranges(x) ## S3 method for class 'oxcAARCalibratedDate' get_sigma_ranges(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_sigma_ranges(x)
x |
an object of class oxcAARCalibratedDate or oxcAARCalibratedDatesList |
a list of three data.frames or a list of those lists
Other getter functions:
get_bp(),
get_cal_curve(),
get_name(),
get_posterior_probabilities(),
get_posterior_sigma_ranges(),
get_raw_probabilities(),
get_std()
## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_sigma_ranges(x) y <- oxcalCalibrate(5000, 20)[[1]] get_sigma_ranges(y) ## End(Not run)## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_sigma_ranges(x) y <- oxcalCalibrate(5000, 20)[[1]] get_sigma_ranges(y) ## End(Not run)
queries values from date objects
get_std(x) ## Default S3 method: get_std(x) ## S3 method for class 'oxcAARCalibratedDate' get_std(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_std(x)get_std(x) ## Default S3 method: get_std(x) ## S3 method for class 'oxcAARCalibratedDate' get_std(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_std(x)
x |
an object of class oxcAARCalibratedDate or oxcAARCalibratedDatesList |
an integer or a numeric vector
Other getter functions:
get_bp(),
get_cal_curve(),
get_name(),
get_posterior_probabilities(),
get_posterior_sigma_ranges(),
get_raw_probabilities(),
get_sigma_ranges()
## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_std(x) y <- oxcalCalibrate(5000, 20)[[1]] get_std(y) ## End(Not run)## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_std(x) y <- oxcalCalibrate(5000, 20)[[1]] get_std(y) ## End(Not run)
Transforms oxcAAR output to a tidy data format. See http://vita.had.co.nz/papers/tidy-data.html and https://CRAN.R-project.org/package=broom
get_tidy_oxcalresult(x) ## Default S3 method: get_tidy_oxcalresult(x) ## S3 method for class 'oxcAARCalibratedDate' get_tidy_oxcalresult(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_tidy_oxcalresult(x)get_tidy_oxcalresult(x) ## Default S3 method: get_tidy_oxcalresult(x) ## S3 method for class 'oxcAARCalibratedDate' get_tidy_oxcalresult(x) ## S3 method for class 'oxcAARCalibratedDatesList' get_tidy_oxcalresult(x)
x |
an object of class oxcAARCalibratedDate or oxcAARCalibratedDatesList |
a data.frame (with list columns)
## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_tidy_oxcalresult(x) y <- oxcalCalibrate(5000, 20)[[1]] get_tidy_oxcalresult(y) ## End(Not run)## Not run: x <- oxcalCalibrate(c(5000, 4500, 3000), c(20, 50, 60)) get_tidy_oxcalresult(x) y <- oxcalCalibrate(5000, 20)[[1]] get_tidy_oxcalresult(y) ## End(Not run)
Checks if a variable is of class oxcAARCalibratedDate
is.oxcAARCalibratedDate(x)is.oxcAARCalibratedDate(x)
x |
An object to test. |
TRUE if x inherits from "oxcAARCalibratedDate",
FALSE otherwise.
Checks if a variable is of class oxcAARCalibratedDatesList
is.oxcAARCalibratedDatesList(x)is.oxcAARCalibratedDatesList(x)
x |
An object to test. |
TRUE if x inherits from "oxcAARCalibratedDatesList",
FALSE otherwise.
The function oxcAARCalibratedDate() creates an object representing a single
calibrated radiocarbon date (and optionally its posterior, if a model was run in OxCal).
oxcAARCalibratedDate( name, type, bp, std, cal_curve, sigma_ranges, raw_probabilities, posterior_probabilities = NA, posterior_sigma_ranges = NA )oxcAARCalibratedDate( name, type, bp, std, cal_curve, sigma_ranges, raw_probabilities, posterior_probabilities = NA, posterior_sigma_ranges = NA )
name |
A string giving the name of the date (usually the lab number). |
type |
A string giving the type of the date in OxCal terminology (e.g. "R_Date", "R_Simulate"). |
bp |
An integer/numeric giving the uncalibrated BP value. |
std |
An integer/numeric giving the standard deviation. |
cal_curve |
A list with calibration curve information (name, resolution, bp, bc, sigma). |
sigma_ranges |
A list of three elements (one, two, three sigma), each a data frame
with columns |
raw_probabilities |
A data frame with columns |
posterior_probabilities |
A data frame with columns |
posterior_sigma_ranges |
A list of three elements (one, two, three sigma), each a data frame
with columns |
An object of class "oxcAARCalibratedDate".
A list of calibrated dates, i.e. objects of class oxcAARCalibratedDate.
An object of class "oxcAARCalibratedDatesList" (a list).
Wraps an Oxcal string into a Oxcal sum function
oxcal_Sum(oxcal_string, name = " Sum ")oxcal_Sum(oxcal_string, name = " Sum ")
oxcal_string |
The Oxcal script that should be wrapped (vector or single string) |
name |
The name attribute for the resulting sum function |
A new oxcal script as string
Calibrates a 14C date using oxcal
oxcalCalibrate(bp, std, names = 1:length(bp))oxcalCalibrate(bp, std, names = 1:length(bp))
bp |
A vector containing the bp dates of the measurements |
std |
A vector containing the standard deviations of the measurements |
names |
The names of the measurements, usually the Laboratory numbers |
An object of class oxcAARCalibratedDatesList
Simulates 14C dates using oxcal
oxcalSimulate(c_date, std, names = 1:length(c_date))oxcalSimulate(c_date, std, names = 1:length(c_date))
c_date |
A vector containing the calendar dates to be simulated |
std |
A vector containing the standard deviations for the simulated dates |
names |
The names of the measurements, usually the Laboratory numbers |
An object of class oxcAARCalibratedDatesList
Sum calibration for simulated dates
oxcalSumSim( timeframe_begin, timeframe_end, n, stds, date_distribution = c("equidist", "uniform") )oxcalSumSim( timeframe_begin, timeframe_end, n, stds, date_distribution = c("equidist", "uniform") )
timeframe_begin, timeframe_end
|
beginning and end of the time frame for which dates should be simulated |
n |
the number of dates that should be simulated |
stds |
either one standard deviation for all dates or a vector of standard deviations with length n |
date_distribution |
a character string indicating which method should be used to distribute the dates in the given time frame, can be abbreviated |
The dates can be distributed using one of the following methods: 'equidist' distributed the n dates within the time frame with equal distance, 'uniform' random samples n dates from the given time interval with uniform distribution
A list containing the following components:
dates |
the dates for the simulated sum calibration |
probabilities |
the probabilities for the simulated sum calibration |
date_distribution |
the distribution method used for the dates |
Takes the output of Oxcal as vector of strings (one string per line) and parse it as list.
parseFullOxcalOutput(output)parseFullOxcalOutput(output)
output |
The output of Oxcal as vector of strings (one string per line). |
A list containing all informations provided by Oxcal as list.
Takes the output of Oxcal as vector of strings (one string per line) and parse it as list.
parseOxcalOutput(result, first = FALSE, only.R_Date = TRUE)parseOxcalOutput(result, first = FALSE, only.R_Date = TRUE)
result |
The output of Oxcal as vector of strings (one string per line). |
first |
Return the first date only |
only.R_Date |
Return the informations for R_Dates |
A list containing all informations provided by Oxcal as list.
Phase takes a set of R_Dates as vectors, and returns a bit of oxcal code that can be used to feed it into oxcal. In this code the R_Dates are encapsulated in an OxCal Phases, one Phase for each string. For details concerning the Oxcal simulation please consult the help page of Oxcal.
Phase(r_dates_strings, names = "")Phase(r_dates_strings, names = "")
r_dates_strings |
a vector containing strings of OxCal code, usually consisting of R_Date commands, but any other code strings might be used that can be interpreted by OxCal within a Phase |
names |
a optional vector of names for the resulting Phases |
a string containing the respective Oxcal code
Plot an oxcAARCalibratedDate
## S3 method for class 'oxcAARCalibratedDate' plot(x, use_ggplot = TRUE, ...)## S3 method for class 'oxcAARCalibratedDate' plot(x, use_ggplot = TRUE, ...)
x |
|
use_ggplot |
Logical. If |
... |
Further arguments passed to the underlying plotting function. |
For lists of length 1, this dispatches to plot() for
oxcAARCalibratedDate. For longer lists, it uses either
ggplot2 (ridge plots) or base graphics.
## S3 method for class 'oxcAARCalibratedDatesList' plot(x, use_ggplot = TRUE, ...)## S3 method for class 'oxcAARCalibratedDatesList' plot(x, use_ggplot = TRUE, ...)
x |
|
use_ggplot |
Logical. If |
... |
Further arguments passed to the underlying plotting function. |
Print an oxcAARCalibratedDate
## S3 method for class 'oxcAARCalibratedDate' print(x, ...)## S3 method for class 'oxcAARCalibratedDate' print(x, ...)
x |
|
... |
Passed to |
Print an oxcAARCalibratedDatesList
## S3 method for class 'oxcAARCalibratedDatesList' print(x, ...)## S3 method for class 'oxcAARCalibratedDatesList' print(x, ...)
x |
|
... |
Further arguments passed to |
Downloads the latest version of Oxcal and sets the executable path correctly
quickSetupOxcal(os = Sys.info()["sysname"], path = tempdir())quickSetupOxcal(os = Sys.info()["sysname"], path = tempdir())
os |
The operating system of the workstation. Default: automatic determination. Options:
|
path |
The path to the directory where Oxcal is or should be stored. Default: "tempdir()". I recommend thought to install it permanently. |
Clemens Schmid
## Not run: quickSetupOxcal() ## End(Not run)## Not run: quickSetupOxcal() ## End(Not run)
R_Date takes names, BP dates and standard deviation for those dates as vectors, and returns a bit of oxcal code that can be used to feed it into oxcal. For details concerning the Oxcal calibration please consult the help page of Oxcal.
R_Date(names, r_dates, stds)R_Date(names, r_dates, stds)
names |
a vector of names for the dates |
r_dates |
a vector containing the BP dates that should be calibrated |
stds |
a vector containing the standard deviation that should be calibrated (length 1 or same length as r_dates) |
a string containing the respective Oxcal code
R_Simulate takes names, calendar dates and standard deviation for those dates as vectors, and returns a bit of oxcal code that can be used to feed it into oxcal. For details concerning the Oxcal simulation please consult the help page of Oxcal.
R_Simulate(c_dates, stds, names = seq_along(c_dates))R_Simulate(c_dates, stds, names = seq_along(c_dates))
c_dates |
a vector containing the calendar dates that should be simulated |
stds |
a vector containing the standard deviation that should be simulated (length 1 or same length as c_dates) |
names |
a vector of names for the resulting simulated dates |
a string containing the respective Oxcal code
Reads the content of the Oxcal js output file as vector of strings for each line.
readOxcalOutput(output_file)readOxcalOutput(output_file)
output_file |
The path to a Oxcal js output file. |
The content of the Oxcal js output file as vector of strings for each line.
Martin Hinz
Sequence takes a set of Phases or R_Dates as vectors, and returns a bit of oxcal code that can be used to feed it into OxCal. In this code the Phases and/or R_Dates are encapsulated in an OxCal Sequence. For details concerning the Oxcal simulation please consult the help page of Oxcal.
Sequence(sequence_elements, names = "")Sequence(sequence_elements, names = "")
sequence_elements |
a vector containing strings of OxCal code, usually consisting of Phase or R_Date commands, but any other code strings might be used that can be interpreted by OxCal within a Sequence |
names |
a optional vector of names for the resulting Sequences |
a string containing the respective Oxcal code
Stores the path to the oxcal executable it in internally for other functions.
setOxcalExecutablePath(path)setOxcalExecutablePath(path)
path |
The path to the Oxcal executable |
Martin Hinz
## Not run: connectOxcal('/home/martin/Documents/scripte/OxCal/bin/OxCalLinux') ## End(Not run)## Not run: connectOxcal('/home/martin/Documents/scripte/OxCal/bin/OxCalLinux') ## End(Not run)
wrap_in_boundaries takes a set of Phases or R_Dates as vectors, and returns a bit of oxcal code that can be used to feed it into OxCal. In this code the Phases and/or R_Dates are interleaved and wrapped in OxCal Boundaries, the number of Boundaries is equal to the number of strings + 1. The resulting string starts with a boundary, than the OxCal strings from the vector are interleaved with Boundary commands. For details concerning the Oxcal simulation please consult the help page of Oxcal.
wrap_in_boundaries(phases_strings, boundary_names = NA, collapse = FALSE)wrap_in_boundaries(phases_strings, boundary_names = NA, collapse = FALSE)
phases_strings |
a vector containing strings of OxCal code, usually consisting of Phase or R_Date commands, but any other code strings might be used that can be interpreted by OxCal inbetween a Boundary |
boundary_names |
a optional vector of names for the resulting Boundaries (length of phases_strings + 1). If not given, the boundaries are named with consecutive numbers. |
collapse |
if TRUE, return a single string; if FALSE (default), return a character vector (backwards compatible) |
OxCal code (character vector or single string depending on collapse)