purge_shiny_code: Remove shiny-specific code from callstack

Description Usage Arguments Value Note Examples

Description

walk an expression, call or list, replacing canonical shiny server functions with R script equivalent code.

Usage

1

Arguments

x

a call, or expression to strip of shiny-specific functions

Value

the same call or expression, with shiny runtime-specific functionality stripped and replaced with code that will evaluate within an R script.

Note

specifically, a few shiny functions built around a reactive javascript context are reconstructed as base R functions:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(shiny)

code <- quote({
  output$plot <- renderPlot({
    plot(x = mtcars[[input$x]],
         y = mtcars[[input$y]])
  })
  observeEvent(input$give_me_a_happy_message, {
    "you're a great person!"
  })
  output$code <- renderPrint({
    generate_static_code(srv, 'plot')
  })
})

scriptgloss:::purge_shiny_code(code)

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