interactive_call: Call a function interactively

Description Usage Arguments Value See Also Examples

View source: R/utils-cliui.R

Description

Since calling a function needs arguments, we should provide values explicitly to a argument without default value. Except that, we could call it interactively, i.e. we could ask user to provide value for each argument during execution of function.

Usage

1
2
3
interactive_call(fun, quiet = FALSE, debug = FALSE)

interactive_call_(quo_fun, quiet = FALSE, debug = FALSE)

Arguments

fun

a function to be executed.

quiet

a logical of whether display interactive message. Default FALSE means display interactive message in execution.

debug

a logical of whether execute fun in simulation mode or real mode. Default FALSE means to execute function in real mode.

quo_fun

a function quoted by rlang::quo() or rlang::enquo() to be executed.

Value

return value from fun if debug = TRUE, otherwise NULL.

See Also

Other utils_cliui: help_fun(), interactive_fun()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 

# NSE examples -- Usage in interactive mode

# Call a function by prompting user to provide values for arguments
interactive_call(print)

# Call a function interactively which execute without displaying information
interactive_call(print, quiet = TRUE)

# Call a function interactively which execute it in debug mode
interactive_call(print, debug = TRUE)

# SE examples -- Usage in program mode

# Program with SE version function
inter_call <- function(fun) {
  interactive_call_(rlang::quo(fun), quiet = TRUE)
}

inter_call(print)

## End(Not run)

# NSE version of function

chriszheng2016/zstmodelr documentation built on June 13, 2021, 8:59 p.m.