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.1 |
Built: | 2025-02-11 05:28:21 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 Phases dates. If given, for each name a boundary is returned. If not given, one Boundary without name is returned. |
a string containing the respective Oxcal code
Plots calibrated dates on the calibration curve
calcurve_plot( x, dates_sigma_ranges = NULL, uncal_range = TRUE, cal_range = TRUE )
calcurve_plot( x, dates_sigma_ranges = NULL, uncal_range = TRUE, cal_range = TRUE )
x |
an object of class oxcAARCalibratedDate or oxcAARCalibratedDatesList |
dates_sigma_ranges |
character. The sigma range used for the error bars ("two_sigma", "one_sigma" or "three_sigma") |
uncal_range |
logical. If TRUE (default), the plot contains error bars for the the uncalibrated age |
cal_range |
logical. If TRUE (default), the plot contains error bars for the the calibrated age |
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
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 |
a variable |
true if x is a oxcAARCalibratedDate, false otherwise
Checks if a variable is of class oxcAARCalibratedDatesList
is.oxcAARCalibratedDatesList(x)
is.oxcAARCalibratedDatesList(x)
x |
a variable |
true if x is a oxcAARCalibratedDatesList, false otherwise
The function oxcAARCalibratedDate
is used to create an object for a calibrated date.
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 ("R_Date", "R_Simulate", ...) |
bp |
a integer giving the BP value for the date |
std |
a integer giving the standard deviation for the date |
cal_curve |
a list containing information about the calibration curve (name, resolution, bp, bc, sigma) |
sigma_ranges |
a list of three elements (one, two, three sigma), each a data frame with start, end and probability giving |
raw_probabilities |
a data frame of dates and the related probabilities for each date |
posterior_probabilities |
a data frame of dates and the related posterior probabilities for each date |
posterior_sigma_ranges |
a list of three elements (one, two, three sigma), each a data frame with start, end and probability giving for the posterior probabilities |
an object of the class 'oxcAARCalibratedDate'
A List of oxcAARCalibratedDate
an object of the class 'oxcAARCalibratedDatesList'
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 |
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 = T)
parseOxcalOutput(result, first = FALSE, only.R_Date = T)
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
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 |
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 = 1:length(c_dates))
R_Simulate(c_dates, stds, names = 1:length(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 |
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 Phases, one Phase for each string. 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)
wrap_in_boundaries(phases_strings, boundary_names = NA)
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. |
a string containing the respective Oxcal code