R: An unevaluated expression to return .Random.seed if exists

rand_seed {knitr} | R Documentation

## An unevaluated expression to return .Random.seed if exists

### Description

This expression returns `.Random.seed` when `eval(rand_seed)` and `NULL` otherwise.

### Usage

    rand_seed

### Details

It is designed to work with `opts_chunk$set(cache.extra = rand_seed)` for reproducibility of chunks that involve with random number generation. See references.

### References

https://yihui.name/knitr/demo/cache/

### Examples

    eval(rand_seed)
    rnorm(1)  # .Random.seed is created (or modified)
    eval(rand_seed)

[Package knitr version 1.20 Index]