Description Usage Arguments Value Note Examples
walk an expression, call or list, replacing canonical shiny server functions with R script equivalent code.
1 |
x |
a call, or expression to strip of shiny-specific functions |
the same call or expression, with shiny runtime-specific functionality stripped and replaced with code that will evaluate within an R script.
specifically, a few shiny functions built around a reactive javascript context are reconstructed as base R functions:
my_reactive_value <- reactive({ ... })
will become
my_reactive_value <- function() { ... }
All shiny render functions
(output$my_output <- render*({ ... })
) will become
output$my_output <- function() { ... }
calls to observeEvent()
becomes NULL
calls to observe()
becomes NULL
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.