Recursively match calls and modify arguments
Usage
match_calls(
call,
recursive = TRUE,
replace_args = list(),
quoted = FALSE,
envir = parent.frame(),
...
)
Examples
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)) }
))
#> lapply(X = 1:20, FUN = function(i) {
#> textInput(inputId = ns(paste("id_", i)), label = paste("Label ",
#> i))
#> })