Description Usage Arguments Details See Also Examples
View source: R/createCalCurve.R
A function for creating a new calibration curve not already available in Bchron
1 2 3 4 5 6 7 8 |
name |
The name of the new calibration curve |
calAges |
A vector of the calendar/calibrated ages in years before present |
uncalAges |
A vector of values of uncalibrated ages in appropriate units (e.g. 14C years BP) |
oneSigma |
The one sigma (one standard deviation) values in uncalibrated units. If left blank it assumes these are all zero |
pathToCalCurves |
The path to the calibration curves. Will write by default to the working directory |
createFile |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ## Not run:
# 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")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.