---
title: "Introduction to ArchaeoCal"
author: "N. Frerebeau"
date: "2023-12-04"
output:
  markdown::html_format:
    options:
      toc: true
      number_sections: true
bibliography: bibliography.bib
vignette: >
  %\VignetteIndexEntry{Introduction to ArchaeoCal}
  %\VignetteEngine{knitr::knitr}
  %\VignetteEncoding{UTF-8}
---



This vignette uses data available through the [**ArchaeoData**](https://github.com/ArchaeoStat/ArchaeoData) package which is available in a [separate repository](https://archaeostat.r-universe.dev). **ArchaeoData** provides OxCal [@bronkramsey2009] input models.


```r
## Install the latest version
install.packages("ArchaeoData", repos = "https://archaeostat.r-universe.dev")
```


```r
## Load package
library(ArchaeoCal)

## Download OxCal
oxcal_configure()
#> OxCal binary found at /tmp/RtmpDY8HDa/OxCal/bin/OxCalLinux
```


```r
## Read OxCal script from Bosch et al. 2015
path <- system.file("oxcal/ksarakil/ksarakil.oxcal", package = "ArchaeoData")
scr <- readLines(path)

## Print script
# cat(scr, sep = "\n")

## Execute OxCal script
## /!\ this may take a while /!\
out <- oxcal_execute(scr)
#> OxCal v4.4.4 (c) Bronk Ramsey (2021)
#> MCMC analysis
#> Sort	Burn	Trial	Save	Shrink	kPasses	Done	Ok	Convergence
#> [.]	[.]	[.]	[.]		3.0	10.0	100.0	100.0
#> [.]	[.]	[.]	[.]		6.0	20.0	100.0	6.8
#> [.]	[.]	[.]	[.]		12.0	22.2	100.0	14.4
#> [.]	[.]	[.]	[.]		24.0	22.2	100.0	6.2
#> [.]	[.]	[.]	[.]		48.0	22.2	100.0	43.2
#> [.]	[.]	[.]	[.]	[.]	96.0	22.2	100.0	64.5
#> [.]	[.]	[.]	[.]		192.0	22.2	100.0	80.3
#> [.]	[.]	[.]	[.]		384.0	22.2	100.0	83.2
#> [.]	[.]	[.]	[.]		768.0	22.2	100.0	70.5
#> [.]	[.]	[.]	[.]		1152.0	30.0	100.0	95.8
#> [.]	[.]	[.]	[.]		1536.0	40.0	100.0	85.1
#> [.]	[.]	[.]	[.]		1920.0	50.0	100.0	85.1
#> [.]	[.]	[.]	[.]		2304.0	60.0	100.0	85.1
#> [.]	[.]	[.]	[.]		2688.0	70.0	100.0	85.1
#> [.]	[.]	[.]	[.]		3072.0	80.0	100.0	85.1
#> [.]	[.]	[.]	[.]		3456.0	90.0	100.0	85.1
#> [.]	[.]	[.]	[.]		3840.0	100.0	100.0	82.4
#> [.]	[.]	[.]	[.]		4224.0	110.0	100.0	82.4

## Parse OxCal output
res <- oxcal_parse(out)
```


```r
par(mar = c(5, 6, 1, 1) + 0.1)
plot(res)
```

<div class="figure" style="text-align: center">
<img src="./figures/plot-1.png" alt="plot of chunk plot"  />
<p class="caption">plot of chunk plot</p>
</div>

## References
