Average rate_of_return()
Examples
x <- mock_provider(2020:2025)
x |>
dplyr::group_by(group) |>
rate_of_return(payment)
#> # A tibble: 12 × 4
#> year group payment payment_ror
#> <int> <chr> <int> <dbl>
#> 1 2020 A 19487 1
#> 2 2021 A 12441 0.638
#> 3 2022 A 14560 1.17
#> 4 2023 A 12977 0.891
#> 5 2024 A 17726 1.37
#> 6 2025 A 19336 1.09
#> 7 2020 B 13004 1
#> 8 2021 B 10092 0.776
#> 9 2022 B 12158 1.20
#> 10 2023 B 16291 1.34
#> 11 2024 B 16512 1.01
#> 12 2025 B 16307 0.988
x |>
dplyr::group_by(group) |>
rate_of_return(payment) |>
dplyr::summarise(gmean = geomean(payment_ror), .by = group)
#> # A tibble: 2 × 2
#> group gmean
#> <chr> <dbl>
#> 1 A 0.999
#> 2 B 1.04