A function for creating a new calibration curve not already available in Bchron
The name of the new calibration curve
A vector of the calendar/calibrated ages in years before present
A vector of values of uncalibrated ages in appropriate units (e.g. 14C years BP)
The one sigma (one standard deviation) values in uncalibrated units. If left blank it assumes these are all zero
The path to the calibration curves. Will write by default to the working directory
whether to write out the new file or not. Only turned off for testing purposes
All calibration curves are stored by Bchron in the standard R gzipped text format. You can find the location of the calibration curves by typing system.file('data',package='Bchron')
. Any created calibration curve will be converted to this format. However R packages are not allowed to write to this directory so it is up to the user to put the resulting calibration curve file in the appropriate directory. It can then be used as in the examples below. However note that re-installing Bchron will likely over-write previously created calibration curves so you should make sure to store the code used to create it. As a short-cut to copying it by hand you can instead use the file.copy
command in the example below.
if (FALSE) {
# Load in the calibration curve with:
intcal09 <- read.table(system.file("extdata/intcal09.14c", package = "Bchron"), sep = ",")
# Run createCalCurve
createCalCurve(
name = "intcal09", calAges = intcal09[, 1],
uncalAges = intcal09[, 2], oneSigma = intcal09[, 3]
)
# Copy the file to the right place
file.copy(
from = "intcal09.rda",
to = system.file("data", package = "Bchron"),
overwrite = TRUE
) # Only need this if you've run it more than once
# Calibrate the ages under two calibration curves
age_09 <- BchronCalibrate(
ages = 15500, ageSds = 150,
calCurves = "intcal09", ids = "My Date",
pathToCalCurves = getwd()
)
age_20 <- BchronCalibrate(ages = 15500, ageSds = 150, calCurves = "intcal20")
# Finally plot the difference
library(ggplot2)
plot(age_09) +
geom_line(
data = as.data.frame(age_20$Date1),
aes(x = ageGrid, y = densities), col = "red"
) +
ggtitle("Intcal09 vs Intcal20")
}