report_download_handler: Export report as template

Description Usage Arguments Value Examples

Description

Export report as template

Usage

1
2
3
report_download_handler(template, server, ..., format = "pdf_document",
  filename = paste(Sys.Date(), gsub("\\.[^.]+$", "", template), sep = "-"),
  output_options = list(), envir = parent.frame())

Arguments

template

whisker formatted template rmarkdown file to use as the basis for report generation

server

server function to use for code generation

...

additional whisker tags to expand using knit_expand

format

the format to be passed to render

filename

filename to use for generated file. defaults to base filename of template file

output_options

additional options to be passed to render

envir

environment in which to construct report downloader callback

Value

a shiny downloadHandler to manage building and downloading of report

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
## 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 <- report_download_handler('MyReport.Rmd', srv)
}

shinyApp(ui, srv)

## End(Not run)

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