Render
.Rmdreports directly in your browser from a shiny application - no download required.
This package adapts the Shiny -> R Markdown report generation
workflow to remove the need to download a file and open it manually.
shinyReports provides UI and server-side elements to knit
the .Rmd file and automatically push the HTML content to a
new browser tab.
Install directly from GitHub with:
# install.packages("remotes")
remotes::install_github("aes21/shinyReports")Ensure your R Markdown file sits within your app structure. The YAML heading of the R Markdown file must knit to a HTML document:
---
title: ''
output: html_document
params:
foo: NA
---
The reportButton() function acts as a connection wrapper
for shiny::actionButton to the report download in the
UI.
ui <- fluidPage(
reportButton("knit_report", "Generate Report")
)The renderReport() function contains the server-side
logic to compile a .Rmd file and load the HTML content to
the client.
server <- function(input, output, session) {
renderReport(
"knit_report",
rmd_file = "path/to/rmarkdown.Rmd",
title = "Report Title",
params = list()
)
}The params list is passed directly through to the
.Rmd file, so you can populate reports with reactive values
from your app.
For an example shinyReports application, you can launch
the demo directly from your R console:
library(shinyReports)
# launch example app
shiny::runApp(system.file("examples", package = "shinyReports"))