Global Static Variable

Usage

sVariable(default = NULL)

Arguments

default
default value for the static variable.

Description

sVariable defines a function that acts as a global static variable.

Examples

# define variable
x <- sVariable(1)
# get value (default)
x()
[1] 1
# set new value: return old value
old <- x(3)
old
[1] 1
# get new value
x()
[1] 3