我试图在 Rstudio 中重现这个例子,它工作得很好。然后我把所有东西放在一起下载闪亮的模板!但它不起作用:
library(shiny)
library(ReporteRs)
library(ReporteRsjars)
library( ggplot2 )
library( magrittr )
library( ggplot2 )
library( magrittr )
ui<- fluidPage(
downloadButton('downloadData', 'Download')
)
server<- function(input, output,session) {
output$downloadData <- downloadHandler(
filename = "file.docx",
content = function(file) {
target_file <- "bookmark_example.docx" # file to produce
template <- system.file(package = "ReporteRs",
"templates/bookmark_example.docx" ) # template example
doc = docx(template=template)
ft <- vanilla.table( data = head(iris), add.rownames=TRUE )
myplot1 <- ggplot(data = iris, aes(Sepal.Length, Petal.Length, color = Species),
alpha = I(0.7) )
doc %>%
addParagraph( value = "Jane Doe", stylename = "small", bookmark = "AUTHOR" ) %>%
addParagraph( value = "John Doe", stylename = "small", bookmark = "REVIEWER" ) %>%
addFlexTable( flextable = ft, bookmark = "DATA" ) %>%
addPlot( fun = print, x = myplot1, bookmark = "PLOT" ) %>%
writeDoc( file = target_file)
}
)
}
shinyApp(ui=ui,server=server)
如果我运行服务器内容,而不添加闪亮,它会更新我的模板,但是当我点击下载按钮时,它会返回:
知道错在哪里???