match_calls: Recursively match calls and modify arguments

Description Usage Arguments Value Examples

View source: R/language.R

Description

Recursively match calls and modify arguments

Usage

1
2
3
4
5
6
7
8
match_calls(
  call,
  recursive = TRUE,
  replace_args = list(),
  quoted = FALSE,
  envir = parent.frame(),
  ...
)

Arguments

call

an R expression

recursive

logical, recursively match calls, default is true

replace_args

named list of functions, see examples

quoted

logical, is call quoted

envir

which environment should call be evaluated

...

other parameters passing to match.call

Value

A nested call with all arguments matched

Examples

1
2
3
4
5
6
7
8
9
library(dipsaus); library(shiny)

# In shiny modules, we might want to add ns() to inputIds
# In this example, textInput(id) will become textInput(ns(id))
match_calls(lapply(1:20, function(i){
  textInput(paste('id_', i), paste('Label ', i))
}), replace_args = list(
  inputId = function(arg, call){ as.call(list(quote(ns), arg)) }
))

dipsaus documentation built on Sept. 6, 2021, 5:08 p.m.