trim_shinyApp: Trim code after shinyApp() call

Description Usage Arguments Value Examples

Description

Replaces shinyApp() call with NULL and removes all following code from a block of code. This is particularly useful to recreate the server state as none of the code after a shinyApp() call will be reached.

Usage

1

Arguments

x

code or expression to strip of code at the shinyApp() call

Value

the code or expression with all code at and beyond the shinyApp() call removed.

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
code <- quote({
  ui <- fluidPage(
    selectInput('x', 'x axis', choices = names(mtcars)),
    selectInput('y', 'y axis', choices = names(mtcars)),
    plotOutput('plot'),
  )
  
  srv <- function(input, output, session) {
    output$plot <- renderPlot({
      plot(x = mtcars[[input$x]],
        y = mtcars[[input$y]])
    })
  }

  shinyApp(ui, srv)

  print('this is some code after the shinyApp() call')
  
  a <- 1
  b <- 2
})

scriptgloss:::trim_shinyApp(code)



code2 <- quote({
  ui <- fluidPage(
    selectInput('x', 'x axis', choices = names(mtcars)),
    selectInput('y', 'y axis', choices = names(mtcars)),
    plotOutput('plot'),
  )
  
  srv <- function(input, output, session) {
    output$plot <- renderPlot({
      plot(x = mtcars[[input$x]],
        y = mtcars[[input$y]])
    })
  }

  a <- 1

  if (a == 1) {
    shinyApp(ui, srv)
  } else {
    print("This app never got launched!")
  }

  print('this is some code after the shinyApp() call')
  
  b <- 2
})

scriptgloss:::trim_shinyApp(code2)

dgkf/scriptgloss documentation built on June 8, 2019, 8:43 p.m.