make_observer: Create function for keeping track of values

Description Usage Value Examples

Description

Create function for keeping track of values

Usage

1

Value

A function with signature ‘function(x, show = FALSE)’. If ‘show’ is TRUE, the function returns a character vector with all values (coerced to "character") that it has ‘seen’ so far. If ‘show’ is FALSE and argument ‘x’ was ‘seen’ before, the function returns "TRUE", otherwise it returns "FALSE". The argument ‘x’ must be a of length 1 and class "character", "numeric", or "integer". If the argument is of class "numeric" or "integer", conversion to class "character" is done via as.character. The order of element in the list returned if ‘show’ is TRUE is not guaranteed to be the same order in which the values were ‘seen’.

Examples

1
2
3
seen <- make_observer()
for (i in c(1:5, 1:5)) pr("Seen ", i, " -> ", seen(i))
seen(show = TRUE)

cbaumbach/miscFun documentation built on May 13, 2019, 1:48 p.m.