This function expands a range by adding noise to the left of the minimum values and to the right of the maximum values.
See also
Other helpers:
exclude()
,
join_to()
,
summarize_range()
,
unnest_product()
Examples
library(tibble)
set.seed(123)
data <- tibble(min = -2:2, max = -1:3)
data |> jitter_range(amount = 0.1)
#> # A tibble: 5 × 4
#> min max min_jitter max_jitter
#> <int> <int> <dbl> <dbl>
#> 1 -2 -1 -2.18 -0.920
#> 2 -1 0 -1.01 0.00933
#> 3 0 1 -0.0182 1.09
#> 4 1 2 0.990 2.07
#> 5 2 3 1.98 3.27
data |> jitter_range(amount = 2)
#> # A tibble: 5 × 4
#> min max min_jitter max_jitter
#> <int> <int> <dbl> <dbl>
#> 1 -2 -1 -3.67 -0.911
#> 2 -1 0 -1.18 1.61
#> 3 0 1 -0.562 1.87
#> 4 1 2 0.157 3.45
#> 5 2 3 -0.823 6.22