Learn R Programming

toscutil (version 2.8.0)

stub: Stub Function Arguments

Description

stub() assigns all arguments of a given function as symbols to the specified environment (usually the current environment)

Usage

stub(func, ..., envir = parent.frame())

Value

list of symbols that are assigned to envir

Arguments

func

function for which the arguments should be stubbed

...

non-default arguments of func

envir

environment to which symbols should be assigned

Details

Stub is thought to be used for interactive testing and unit testing. It does not work for primitive functions.

Examples

Run this code
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