powered by
stub() assigns all arguments of a given function as symbols to the specified environment (usually the current environment)
stub()
stub(func, ..., envir = parent.frame())
list of symbols that are assigned to envir
envir
function for which the arguments should be stubbed
non-default arguments of func
func
environment to which symbols should be assigned
Stub is thought to be used for interactive testing and unit testing. It does not work for primitive functions.
f <- function(x, y = 2, z = 3) x + y + z args <- stub(f, x = 1) # assigns x = 1, y = 2 and z = 3 to current env
Run the code above in your browser using DataLab