Skip to contents

Execute an Oxcal Script

Usage

oxcal_execute(
  script,
  file = NULL,
  output = c("js", "log", "txt", "csv"),
  timeout = 0
)

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.

output

A character string specifying the file extension to be returned (see below). It must be one of "js", "log", "txt" or "csv".

timeout

An integer value specifying the timeout in seconds, ignored if 0. This is a limit for the elapsed time running OxCal. Fractions of seconds are ignored (see system2()).

Value

Invisibly returns the path to the output file.

Note

Adapted from oxcAAR::executeOxcalScript().

See also

Author

M. Hinz, N. Frerebeau

Examples

if (FALSE) {
## Download OxCal
oxcal_setup()

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

## 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, curve = FALSE)
plot(res, curve = TRUE)

as.data.frame(res)
}