在我的Rmarkdownfile
中,我想下载我的.rmd
作为html
文件,但我得到以下错误。
警告:文件错误。无法打开连接。
我认为这是因为外部文件包含源(…),但我不知道为什么。在外部文件中,我连接到一个数据库。
---
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(rmarkdown)
source('R/load_data.R')
```
```{r}
output$export_btn<- downloadHandler(
filename = "report.html",
content = function(file) {
tempReport <- file.path(tempdir(), "test.Rmd")
file.copy("test.Rmd", tempReport, overwrite = TRUE)
out<-render(tempReport, html_document())
file.rename(out,file)
}
)
```
将file
传递给函数content = function(file)
。file
是默认的R函数。你的意思是将filename
传递给函数吗?
output$export_btn<- downloadHandler(
filename = "report.html",
content = function(filename) {
tempReport <- file.path(tempdir(), "test.Rmd")
file.copy("test.Rmd", tempReport, overwrite = TRUE)
out<-render(tempReport, html_document())
file.rename(out,filename)
}
)