test_that("howmuchC14 returns expected C14 atoms", {
expect_equal(unname(result), 115446, tolerance = 1e-5)
test_that("adjust.fractionation returns expected adjusted C14 age", {
expect_equal(result, 5131.286, tolerance = 1e-5)
test_that("adjust.background returns expected background-corrected C14 age", {
result <- unname(unlist(adjust.background(9000, 50, 45000, 200)))
expect_equal(result[1], 9061.71822, tolerance = 1e-5)
expect_equal(result[2], 50.94971, tolerance = 1e-5)
test_that("find.shells returns expected amount of shells", {
myshells <- find.shells(0, 55, mapsize="small", currents=FALSE)
test_that("weighted_means returns expected weighted mean of selected shells", {
wmns <- weighted_means(myshells[,5], myshells[,6], talk=FALSE)
expect_equal(wmns, c(-146.9, 111.6), tolerance = 1e-5)
test_that("shells.mean returns expected mean of shells", {
test_that("point.estimates returns expected point estimates", {
expect_equal(result[,3], c(68.6, 1.9, 24.5), tolerance = 1e-5)
test_that("l.calib returns expected likelihood", {
expect_equal(result, 0.01721038, tolerance = 1e-5)
test_that("r.calib returns expected random points", {
result <- r.calib(10, 130, 20, bombalert=FALSE)
expect_equal(result[1], 74.13498, tolerance = 1e-5)
test_that("older returns expected probability", {
expect_equal(result, 0.5315318, tolerance = 1e-5)
test_that("p.range returns expected probability", {
expect_equal(result, 0.9134676, tolerance = 1e-5)
test_that("calib.t returns expected ages", {
expect_equal(result$text$x, 2349.163, tolerance = .1)
expect_equal(result, c(676.1406, 23.7443), tolerance = 1e-5)
result <- overlap(y, er, cc=1:2, talk=FALSE)
Cs <- c(.02, .05, .03, .04) # carbon contents of each fraction, out of 1
wghts <- c(5, 4, 2, .5) # weights for all fractions, e.g., in mg
ages <- c(130, 120, 125, NA) # ages of all fractions. The unmeasured one is NA
errors <- c(10, 12, 10, NA) # errors, unmeasured is NA
result <- fractions(150, 20, Cs, wghts, ages, errors, talk=FALSE) # assuming a bulk age of 150 +- 20 C14 B
test_that("contaminate returns correct updated result", {
result <- contaminate(5000, 20, 1, .05, 1, talk=FALSE) # uses MC
result <- clean(5000, 20, 1, 0, 1, talk=FALSE) # no MC
test_that("Monte Carlo output converges with increasing samples", {
r1 <- clean(4000, 30, 10, 2, 1, 0.01, MC=TRUE, its=100, visualise=FALSE, talk=FALSE)
r2 <- clean(4000, 30, 10, 2, 1, 0.01, MC=TRUE, its=5000, visualise=FALSE, talk=FALSE)
expect_true(abs(r1$F14C["mean"] - r2$F14C["mean"]) < 0.01)