report_downloader: Handler for expansion of knitr whisker tags and report...

Description Usage Arguments Examples

Description

Handler for expansion of knitr whisker tags and report generation

Usage

1
2
report_downloader(file, text, format = "pdf_document",
  output_options = NULL)

Arguments

file

the file name to be created

text

Rmarkdown file text to use to render notebook. Often the output of report_from_template.

format

the output format to be passed to render

output_options

additional output options to be passed to render

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
## Not run: 
## MyReport.Rmd (in working directory)
# ---
# title: "My Report"
# ---
#
# ```{r initialize_code}
# {{.code}}
# ```
#
# # My Plot
#
# ```{r plot}
# {{plot}}
# ```

library(shiny)

ui <- fluidPage(
  selectInput('x', 'x axis', choices = names(mtcars)),
  selectInput('y', 'y axis', choices = names(mtcars)),
  downloadButton("export", "Download Report"),
  plotOutput('plot')
)

srv <- function(input, output, session) {
  output$plot <- renderPlot({
    plot(x = mtcars[[input$x]],
         y = mtcars[[input$y]])
  })
  output$export <- downloadHandler(
    filename = 'MyReport.pdf',
    content = function(file) report_downloader(
      file,
      'MyReport.Rmd',
      generate_static_code(srv)
    )
  )
}

shinyApp(ui, srv)

## End(Not run)

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