是否可以使用交互式flexdashboard下载报告?
我已经能够生成应用程序(仪表板)。该应用程序包含多个图形/表格/值框等。在仪表板的末尾,如果用户单击一个按钮,它可能会生成报告,其中包含在仪表板中生成的所有图形/表。 / p>
标题:“费用计算器” 作者:“开发者:Mayank” 运行时间:闪亮 输出: flexdashboard :: flex_dashboard: vertical_layout:滚动
library(shiny)
library(magrittr)
library(shinyWidgets)
library(shinyjs)
useShinyjs(rmd = TRUE)
library(shinydashboard)
library(flexdashboard)
library(lubridate)
library(plm)
library(zoo)
library(plm)
library(zoo)
library(shinyBS)
#Data <- data.frame()
library(shiny)
library(DT)
# observeEvent(input$Add,{
# renderMenu({
# messageItem(from = "ACES", message = "ABCD", icon = shiny::icon("user"), time = Sys.time(),
# href = NULL)})
# })
#verbatimTextOutput("summary")
Input_Panel <- reactive(read.csv("Input_Panel.csv", stringsAsFactors=FALSE))
pickerInput(
inputId = "Tab",
label = "Live search",
choices = c(letters[1:26],1:8),
options = list(
`live-search` = TRUE)
)
# Create placeholder for the downloadButton
#uiOutput("downloadUI")
#downloadLink(outputId = "dwnLink", label = "Download Link")
#radioButtons('format', 'Document format', c('PDF', 'HTML', 'Word'),
#inline = TRUE)
# Create the actual downloadButton
library(gridExtra)
library(grid)
shinyApp(
ui = fillPage(
fillCol(flex = c(NA, 1),
downloadButton('downloadReport'),
radioButtons('format', 'Document format', choices = c('PDF', 'HTML', 'Word'),
inline = TRUE)
)),
server = function(input,output){
x <- reactive(Input_Panel())
y<- input$Tab
output$downloadReport <- downloadHandler(
filename = function() {
paste('my-report', sep = '.', switch(
input$format, PDF = 'pdf', HTML = 'html', Word = 'docx'
))
},
content = function(file) {
# Copy the report file to a temporary directory before processing it, in
# case we don't have write permissions to the current working dir (which
# can happen when deployed).
tempReport <- file.path(tempdir(), "Report.Rmd")
file.copy("Report.Rmd", tempReport, overwrite = TRUE)
# Set up parameters to pass to Rmd document
params <- list(data = (x()) , input = y)
# Knit the document, passing in the `params` list, and eval it in a
# child of the global environment (this isolates the code in the document
# from the code in this app).
rmarkdown::render(tempReport, output_file = file,
params = params,
envir = new.env(parent = globalenv())
)
}
)
}
)
标题:“动态报告” 输出:pdf_document 参数: 数据:不适用
# For PDF output, change the header to have "output: pdf_document". or html_document
#
# Note that due to an issue in rmarkdown, the default value of a parameter in
# the header cannot be `NULL`, so I used a default of `NA` for the default value
# of `n`.
# png(file)
data <- (data.frame("Meaning" = params$data$Meaning[match(input$Tab,params$data$Tab)]))
myTable<- tableGrob(
data,
rows = NULL,
theme = ttheme_default(core = list(bg_params = list(fill = "grey99"))))
grid.draw(myTable)
拟合结果为。 下面是带有回归线的散点图。