Skip to contents

A wrapper for rcarbon::spd() that takes a list of calibrated dates rather than a CalDates object. This allows you to use the output of c14_calibrate() and take advantage of tidy summary syntax (dplyr::group_by(), etc.)

Usage

c14_sum(cal, time_range = NA, ...)

Arguments

cal

A list of cal objects.

time_range

Vector of length 2 indicating the range of calendar dates over which to sum. If left NA, the maximum range of the cal will be used. See details.

...

Optional arguments to be passed to rcarbon::spd()

Value

A calGrid object containing the summed probability distribution.

Details

Unlike rcarbon::spd(), this function will attempt to guess an appropriate time range if it isn't explicitly specified with time_range. It's probably a good idea to specify it.

See also

Other tidy radiocarbon functions: c14_calibrate(), cal()

Examples

data("shub1_radiocarbon")
shub1_radiocarbon %>%
  dplyr::mutate(cal = c14_calibrate(cra, error, normalise = FALSE, verbose = FALSE)) %>%
  dplyr::group_by(phase) %>%
  dplyr::summarise(SPD = c14_sum(cal, spdnormalised = TRUE, verbose = FALSE),
                   .groups = "drop_last")
#> Warning: There were 2 warnings in `dplyr::mutate()`.
#> The first warning was:
#>  In argument: `cal = c14_calibrate(cra, error, normalise = FALSE, verbose =
#>   FALSE)`.
#> Caused by warning:
#> ! stratigraphr::c14_calibrate() is deprecated. Please use c14::c14_calibrate() instead.
#>  Run `dplyr::last_dplyr_warnings()` to see the 1 remaining warning.
#> Warning: There were 34 warnings in `dplyr::summarise()`.
#> The first warning was:
#>  In argument: `SPD = c14_sum(cal, spdnormalised = TRUE, verbose = FALSE)`.
#>  In group 1: `phase = "Phase 1"`.
#> Caused by warning:
#> ! stratigraphr::c14_sum() is deprecated. Please use c14::c14_sum() instead.
#>  Run `dplyr::last_dplyr_warnings()` to see the 33 remaining warnings.
#> # A tibble: 7 × 2
#>   phase   SPD                   
#>   <chr>   <list>                
#> 1 Phase 1 <CalGrid [11,659 × 2]>
#> 2 Phase 2 <CalGrid [560 × 2]>   
#> 3 Phase 3 <CalGrid [473 × 2]>   
#> 4 Phase 4 <CalGrid [1,273 × 2]> 
#> 5 Phase 5 <CalGrid [1,377 × 2]> 
#> 6 Phase 6 <CalGrid [1,155 × 2]> 
#> 7 Phase 7 <CalGrid [1,327 × 2]>