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: 2024-12-17 13:50:13 UTC
Source: https://github.com/ArchaeoStat/ArchaeoCal

Help Index


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

An OxCalOutput object.

Author(s)

N. Frerebeau

See Also

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

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)
)

plot(cal)

## End(Not run)

Setup OxCal

Description

Setup OxCal

Usage

oxcal_configure(
  command = NULL,
  os = NULL,
  ask = TRUE,
  install_location = NULL,
  install_url = NULL,
  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()).

ask

A logical scalar: if OxCal is not installed, should the user be asked to download it? If FALSE and R is being used interactively, will raise an error if the OxCal executable cannot be found. If FALSE and R is not being used interactively, will try to download OxCal.

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.

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(), plot()

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)

plot(res)
plot(res, likelihood = TRUE, posterior = FALSE)
plot(res, likelihood = FALSE, posterior = TRUE)

## End(Not run)

Execute an Oxcal Script

Description

Execute an Oxcal Script

Usage

oxcal_execute(
  script,
  file = NULL,
  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.

verbose

A logical scalar: should status updates be displayed?

...

Further parameters to be passed to system2().

Value

A list with 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(), plot()

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)

plot(res)
plot(res, likelihood = TRUE, posterior = FALSE)
plot(res, likelihood = FALSE, posterior = TRUE)

## 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(), plot()

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)

plot(res)
plot(res, likelihood = TRUE, posterior = FALSE)
plot(res, likelihood = FALSE, posterior = TRUE)

## End(Not run)

Read and Parse OxCal Output

Description

Read and Parse OxCal Output

Usage

oxcal_parse(object)

## S4 method for signature 'list'
oxcal_parse(object)

## S4 method for signature 'character'
oxcal_parse(object)

Arguments

object

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

Value

An OxCalOutput object.

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(), plot()

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)

plot(res)
plot(res, likelihood = TRUE, posterior = FALSE)
plot(res, likelihood = FALSE, posterior = TRUE)

## End(Not run)

Plot OxCal Output

Description

Plot OxCal Output

Usage

## S4 method for signature 'OxCalOutput,missing'
plot(
  x,
  likelihood = TRUE,
  posterior = TRUE,
  warnings = TRUE,
  col.likelihood = "grey",
  col.posterior = "blue",
  lty.likelihood = "solid",
  lty.posterior = "dashed",
  main = NULL,
  sub = NULL,
  ann = graphics::par("ann"),
  axes = TRUE,
  frame.plot = FALSE,
  panel.first = NULL,
  panel.last = NULL,
  ...
)

Arguments

x

An OxCalOutput object.

likelihood

A logical scalar: should likelihood be drawn?

posterior

A logical scalar: should posterior distribution be drawn?

warnings

A logical scalar: should warnings be plotted?

col.likelihood, col.posterior

A character string specifying the color of the density.

lty.likelihood, lty.posterior

A character string or numeric value specifying the line type of the lines.

main

A character string giving a main title for the plot.

sub

A character string giving a subtitle for the plot.

ann

A logical scalar: should the default annotation (title and x, y and z axis labels) appear on the plot?

axes

A logical scalar: should axes be drawn on the plot?

frame.plot

A logical scalar: should a box be drawn around the plot?

panel.first

An an expression to be evaluated after the plot axes are set up but before any plotting takes place. This can be useful for drawing background grids.

panel.last

An expression to be evaluated after plotting has taken place but before the axes, title and box are added.

...

Other graphical parameters may also be passed as arguments to this function.

Value

plot() is called it for its side-effects: it results in a graphic being displayed. Invisibly returns x.

Author(s)

N. Frerebeau

See Also

Other OxCal tools: oxcal_calibrate(), 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)
)

plot(cal)

## End(Not run)