get_code: Retrieve independent R code as text

Description Usage Arguments Value Examples

Description

Retrieve independent R code as text

Usage

1
get_code(server, ..., envir = parent.frame())

Arguments

server

the server function to pull code from

...

outputs to shake tree upon (or keep all code if no outputs are listed)

envir

the environment in which to evaluate server arguments

Value

a string of code

Examples

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

ui <- fluidPage(
  selectInput('x', 'x axis', choices = names(mtcars)),
  selectInput('y', 'y axis', choices = names(mtcars)),
  plotOutput('plot'),
  verbatimTextOutput('code')
)

srv <- function(input, output, session) {
  output$plot <- renderPlot({
    plot(x = mtcars[[input$x]],
         y = mtcars[[input$y]])
  })
  output$code <- renderText({
    get_code(srv, 'plot')
  })
}

shinyApp(ui, srv)

## End(Not run)

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