Attach a seed to a specific function.
Arguments
- .fn
A function call.
- seed
An integer for reproducibility.
Value
Return the function result with a seed set.
Examples
sample(1:10, 8) %>%
set_seed(123)
#> [1] 3 10 2 8 6 9 1 7
# When we re-run the code, we will get the same result.
sample(1:10, 8) %>%
set_seed(123)
#> [1] 3 10 2 8 6 9 1 7