Running examples in ‘tidyactuarial-Ex.R’ failed
The error most likely occurred in:

> ### Name: mc_annuity
> ### Title: Compute simulated present values for life annuities
> ### Aliases: mc_annuity
> 
> ### ** Examples
> 
> life_table <- tibble::tibble(
+   age = 40:100,
+   qx = seq(0.002, 1, length.out = 61)
+ )
> 
> # Annual whole life annuity-due
> life_table |>
+   simulate_lifetime(age = 40, n_sim = 1000, seed = 123) |>
+   mc_annuity(
+     rate = 0.05,
+     annuity = "whole_life",
+     payment = 1,
+     payments_per_year = 1,
+     timing = "due"
+   )
# A tibble: 1,000 × 20
   sim_id   age method  fractional    Kx    Tx  rate interest_type     m
    <int> <dbl> <chr>   <chr>      <dbl> <dbl> <dbl> <chr>         <dbl>
 1      1    40 inverse udd            6  6.27  0.05 effective         1
 2      2    40 inverse udd           13 13.6   0.05 effective         1
 3      3    40 inverse udd            8  8.16  0.05 effective         1
 4      4    40 inverse udd           15 15.9   0.05 effective         1
 5      5    40 inverse udd           17 17.8   0.05 effective         1
 6      6    40 inverse udd            2  2.48  0.05 effective         1
 7      7    40 inverse udd            9  9.77  0.05 effective         1
 8      8    40 inverse udd           15 15.3   0.05 effective         1
 9      9    40 inverse udd            9  9.07  0.05 effective         1
10     10    40 inverse udd            8  8.44  0.05 effective         1
# ℹ 990 more rows
# ℹ 11 more variables: effective_rate <dbl>, discount_factor <dbl>,
#   annuity <chr>, payment <dbl>, payments_per_year <dbl>,
#   deferral_years <dbl>, timing <chr>, n_payments <int>,
#   first_payment_time <dbl>, last_payment_time <dbl>, pv_annuity <dbl>
> 
> # Monthly whole life annuity-due with total annual payment equal to 1
> life_table |>
+   simulate_lifetime(
+     age = 40,
+     n_sim = 1000,
+     fractional = "udd",
+     seed = 123
+   ) |>
+   mc_annuity(
+     rate = 0.05,
+     annuity = "whole_life",
+     payment = 1 / 12,
+     payments_per_year = 12,
+     timing = "due"
+   )
# A tibble: 1,000 × 20
   sim_id   age method  fractional    Kx    Tx  rate interest_type     m
    <int> <dbl> <chr>   <chr>      <dbl> <dbl> <dbl> <chr>         <dbl>
 1      1    40 inverse udd            6  6.27  0.05 effective         1
 2      2    40 inverse udd           13 13.6   0.05 effective         1
 3      3    40 inverse udd            8  8.16  0.05 effective         1
 4      4    40 inverse udd           15 15.9   0.05 effective         1
 5      5    40 inverse udd           17 17.8   0.05 effective         1
 6      6    40 inverse udd            2  2.48  0.05 effective         1
 7      7    40 inverse udd            9  9.77  0.05 effective         1
 8      8    40 inverse udd           15 15.3   0.05 effective         1
 9      9    40 inverse udd            9  9.07  0.05 effective         1
10     10    40 inverse udd            8  8.44  0.05 effective         1
# ℹ 990 more rows
# ℹ 11 more variables: effective_rate <dbl>, discount_factor <dbl>,
#   annuity <chr>, payment <dbl>, payments_per_year <dbl>,
#   deferral_years <dbl>, timing <chr>, n_payments <int>,
#   first_payment_time <dbl>, last_payment_time <dbl>, pv_annuity <dbl>
> 
> # Quarterly temporary life annuity-immediate
> life_table |>
+   simulate_lifetime(
+     age = 40,
+     n_sim = 1000,
+     fractional = "udd",
+     seed = 123
+   ) |>
+   mc_annuity(
+     rate = 0.05,
+     annuity = "temporary",
+     term = 20,
+     payment = 1 / 4,
+     payments_per_year = 4,
+     timing = "immediate"
+   )
# A tibble: 1,000 × 21
   sim_id   age method  fractional    Kx    Tx  rate interest_type     m
    <int> <dbl> <chr>   <chr>      <dbl> <dbl> <dbl> <chr>         <dbl>
 1      1    40 inverse udd            6  6.27  0.05 effective         1
 2      2    40 inverse udd           13 13.6   0.05 effective         1
 3      3    40 inverse udd            8  8.16  0.05 effective         1
 4      4    40 inverse udd           15 15.9   0.05 effective         1
 5      5    40 inverse udd           17 17.8   0.05 effective         1
 6      6    40 inverse udd            2  2.48  0.05 effective         1
 7      7    40 inverse udd            9  9.77  0.05 effective         1
 8      8    40 inverse udd           15 15.3   0.05 effective         1
 9      9    40 inverse udd            9  9.07  0.05 effective         1
10     10    40 inverse udd            8  8.44  0.05 effective         1
# ℹ 990 more rows
# ℹ 12 more variables: effective_rate <dbl>, discount_factor <dbl>,
#   annuity <chr>, payment <dbl>, payments_per_year <dbl>, term <dbl>,
#   deferral_years <dbl>, timing <chr>, n_payments <int>,
#   first_payment_time <dbl>, last_payment_time <dbl>, pv_annuity <dbl>
> 
> # Monthly joint-life annuity using a multiple-life status
> life_table |>
+   simulate_lifetimes(
+     ages = c(60, 58),
+     n_sim = 1000,
+     fractional = "udd",
+     seed = 123
+   ) |>
+   mc_multilife_status(status = "joint_life") |>
+   mc_annuity(
+     rate = 0.04,
+     annuity = "whole_life",
+     payment = 1 / 12,
+     payments_per_year = 12,
+     timing = "due",
+     k_col = "K_status",
+     tx_col = "T_status"
+   )
Error in findInterval(x = u, vec = c(0, dist$cdf), rightmost.closed = TRUE) : 
  'vec' must be sorted non-decreasingly and not contain NAs
Calls: mc_annuity ... <Anonymous> -> <Anonymous> -> simulate_lifetime -> findInterval
Execution halted