Learn R Programming

rush (version 0.4.1)

with_rng_state: 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)

Value

any

Arguments

fun

(function)
Function to run.

args

(list)
Arguments to pass to fun.

seed

(integer)
RNG state to set before running fun.

Examples

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

Run the code above in your browser using DataLab