evalCode: Evaluate strings with error popups

Description Usage Arguments Value Examples

View source: R/evalCode.R

Description

evalCode tries to evaluate code given as a sting. In case of an error, a modal pops up showing the resulting error message.

Usage

1
evalCode(code, env = parent.frame())

Arguments

code

A character of length one giving the code to be evaluated.

env

The environment where the code should be evaluated. Defaults to the calling environment.

Value

The result of the specified expression or NULL in case of an error

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
shinyApp(
  fluidPage(
    textAreaInput("code", "code", "# intended typo\nrnrm(100)"),
    actionButton("evaluate", "evaluate"),
    verbatimTextOutput("result")
  ),
  function(input, output, session){
    res <- eventReactive(
      input$evaluate,
      evalCode(input$code)
    )
    output$result <- renderPrint(res())
  }
)

## End(Not run)

statistikat/codeModules documentation built on Feb. 17, 2021, 11:42 a.m.