with_rng_state: Set RNG Sate before Running a Function

View source: R/helper.R

with_rng_stateR Documentation

Set RNG Sate before Running a Function

Description

This function sets the rng state before running a function. Use with caution. The global environment is changed.

Usage

with_rng_state(fun, args, seed)

Arguments

fun

(function)
Function to run.

args

(list)
Arguments to pass to fun.

seed

(integer)
RNG state to set before running fun.

Value

any

Examples

with_rng_state(runif, list(n = 1), .Random.seed)

rush documentation built on Sept. 11, 2024, 9:15 p.m.