Package 'ArchaeoCal'

Title: An R Interface to 'OxCal'
Description: What the package does (one paragraph).
Authors: Nicolas Frerebeau [aut, cre] (<https://orcid.org/0000-0001-5759-4944>, Université Bordeaux Montaigne)
Maintainer: Nicolas Frerebeau <[email protected]>
License: GPL (>= 3)
Version: 0.0.0.9000
Built: 2025-01-17 18:24:59 UTC
Source: https://github.com/ArchaeoStat/ArchaeoCal

Help Index


Coerce to a Data Frame

Description

Coerce to a Data Frame

Usage

## S3 method for class 'OxCalResults'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

Arguments

x

A list returned by oxcal_parse().

row.names

A character vector giving the row names for the data frame description, or NULL.

optional

A logical scalar. If FALSE then the names of the variables in the data frame are checked to ensure that they are syntactically valid variable names and are not duplicated.

...

Currently not used.

Value

A data.frame with the following columns:

name
operation
type
date
error
agreement
convergence
like_range

A list giving the confidence intervals of the likelihood.

like_density

A list giving the likelihood.

post_range

A list giving the confidence intervals of the posterior probability.

post_density

A list giving the posterior probability.


14C Calibration with OxCal

Description

14C Calibration with OxCal

Usage

oxcal_calibrate(names, dates, errors, curve = "IntCal20")

Arguments

names

A character vector specifying the names of the dates (e.g. laboratory codes).

dates

A numeric vector giving the BP dates to be calibrated.

errors

A numeric vector giving the standard deviation of the dates to be calibrated.

curve

A character string specifying the calibration curve to be used.

Value

A list with class OxCalResults (see oxcal_parse()).

Author(s)

N. Frerebeau

See Also

Other OxCal tools: oxcal_configure(), oxcal_execute(), oxcal_install(), oxcal_parse()

Examples

## Not run: 
## Download OxCal
oxcal_configure()

## Calibrate 14C dates
cal <- oxcal_calibrate(
  names = c("X","Y"),
  dates = c(5000, 4500),
  errors = c(45, 35)
)

as.data.frame(cal)

## End(Not run)

Setup OxCal

Description

Setup OxCal

Usage

oxcal_configure(
  command = NULL,
  os = NULL,
  install = TRUE,
  install_location = NULL,
  install_url = NULL,
  ask = TRUE,
  verbose = getOption("ArchaeoCal.verbose")
)

Arguments

command

A character string specifying the path to the OxCal directory.

os

A character string specifying the operating system of the workstation. It must be one of "Linux", "Windows" or "Darwin". If NULL (the default), the operating system will be determined automatically (see Sys.info()).

install

A logical scalar: if OxCal binary is not found, should it be downloaded and installed?

install_location

A character string specifying the directory to extract OxCal files to. It will be created if necessary (see utils::unzip()).

install_url

A character string specifying the url from which OxCal could be installed.

ask

A logical scalar: if OxCal is not installed, should the user be asked before downloading it?

verbose

A logical scalar: should status updates be displayed?

Details

Downloads the latest version of Oxcal (if needed) and sets the executable path correctly.

Value

Invisibly returns the path to the OxCal executable.

Author(s)

N. Frerebeau

See Also

Other OxCal tools: oxcal_calibrate(), oxcal_execute(), oxcal_install(), oxcal_parse()

Examples

## Not run: 
## Download OxCal
oxcal_configure()

## Custom script
scr <- 'Plot()
 {
  Sequence("Sequence1")
  {
   Boundary("Begin");
   Phase("Phase1")
   {
    R_Date("Lab-1",5000,25);
    R_Date("Lab-2",4900,37);
   };
   Boundary("Between");
   Phase("Phase2")
   {
    R_Date("Lab-3",4800,43);
   };
   Boundary("End");
  };
 };'
out <- oxcal_execute(scr)
res <- oxcal_parse(out)

as.data.frame(res)

## End(Not run)

Execute an Oxcal Script

Description

Execute an Oxcal Script

Usage

oxcal_execute(
  script,
  file = NULL,
  mcmc = "MCMC_Sample",
  verbose = getOption("ArchaeoCal.verbose"),
  ...
)

Arguments

script

A character string of instructions for OxCal.

file

A character string naming a file (without extension) to write script to. Output files will be named after file and written to the same directory.

mcmc

A character string giving the name of the output file for the MCMC samples (without extension). It must match the Name argument of OxCal's MCMC_Sample() function. Only used if script contains the MCMC_Sample() command.

verbose

A logical scalar: should status updates be displayed?

...

Further parameters to be passed to system2().

Value

A list with class OxCalOutput containing the following elements:

oxcal

A character string giving the path to the .oxcal file.

js

A character string giving the path to the .js file.

log

A character string giving the path to the .log file.

txt

A character string giving the path to the .txt file.

csv

A character string giving the path to the .csv file.

Author(s)

N. Frerebeau

References

https://c14.arch.ox.ac.uk/oxcalhelp/hlp_analysis_file.html

See Also

Other OxCal tools: oxcal_calibrate(), oxcal_configure(), oxcal_install(), oxcal_parse()

Examples

## Not run: 
## Download OxCal
oxcal_configure()

## Custom script
scr <- 'Plot()
 {
  Sequence("Sequence1")
  {
   Boundary("Begin");
   Phase("Phase1")
   {
    R_Date("Lab-1",5000,25);
    R_Date("Lab-2",4900,37);
   };
   Boundary("Between");
   Phase("Phase2")
   {
    R_Date("Lab-3",4800,43);
   };
   Boundary("End");
  };
 };'
out <- oxcal_execute(scr)
res <- oxcal_parse(out)

as.data.frame(res)

## End(Not run)

Download OxCal

Description

Download OxCal

Usage

oxcal_install(
  install_url = NULL,
  install_location = NULL,
  verbose = getOption("ArchaeoCal.verbose")
)

Arguments

install_url

A character string specifying the url from which OxCal could be installed.

install_location

A character string specifying the directory to extract OxCal files to. It will be created if necessary (see utils::unzip()).

verbose

A logical scalar: should status updates be displayed?

Value

Invisibly returns the path to the OxCal directory.

Author(s)

N. Frerebeau

See Also

Other OxCal tools: oxcal_calibrate(), oxcal_configure(), oxcal_execute(), oxcal_parse()

Examples

## Not run: 
## Download OxCal
oxcal_configure()

## Custom script
scr <- 'Plot()
 {
  Sequence("Sequence1")
  {
   Boundary("Begin");
   Phase("Phase1")
   {
    R_Date("Lab-1",5000,25);
    R_Date("Lab-2",4900,37);
   };
   Boundary("Between");
   Phase("Phase2")
   {
    R_Date("Lab-3",4800,43);
   };
   Boundary("End");
  };
 };'
out <- oxcal_execute(scr)
res <- oxcal_parse(out)

as.data.frame(res)

## End(Not run)

Read and Parse OxCal Output

Description

Read and Parse OxCal Output

Usage

oxcal_parse(path)

## S3 method for class 'OxCalOutput'
oxcal_parse(path)

## S3 method for class 'character'
oxcal_parse(path)

Arguments

path

A character string naming a JavaScript file which the data are to be read from (or a list returned by oxcal_execute()).

Value

A list with class OxCalResults containing the following elements:

ocd

A list of OxCal data which holds the ranges, probability distributions, etc. for each parameter.

model

A list of information about the model.

calib

A list of information about the calibration curve.

Author(s)

N. Frerebeau

References

https://c14.arch.ox.ac.uk/oxcalhelp/hlp_analysis_file.html

See Also

Other OxCal tools: oxcal_calibrate(), oxcal_configure(), oxcal_execute(), oxcal_install()

Examples

## Not run: 
## Download OxCal
oxcal_configure()

## Custom script
scr <- 'Plot()
 {
  Sequence("Sequence1")
  {
   Boundary("Begin");
   Phase("Phase1")
   {
    R_Date("Lab-1",5000,25);
    R_Date("Lab-2",4900,37);
   };
   Boundary("Between");
   Phase("Phase2")
   {
    R_Date("Lab-3",4800,43);
   };
   Boundary("End");
  };
 };'
out <- oxcal_execute(scr)
res <- oxcal_parse(out)

as.data.frame(res)

## End(Not run)