[英]R Shiny: Download preset .csv file
I am working on a shiny app that allows the user to download an existing .csv
file (called template.csv
) that is located on the server (in a folder called "data").我正在开发一个闪亮的应用程序,它允许用户下载位于服务器上的现有
.csv
文件(称为template.csv
)(在名为“data”的文件夹中)。
Using downloadHandler
, I do not get any output.使用
downloadHandler
,我没有得到任何输出。
library(shiny)
ui <- fluidPage(
downloadButton("download", label = "Download")
)
server <- function(input,output) {
output$download <- downloadHandler(
filename <- function() {
"template_output.csv"
}
content <- function(file) {
file.copy("./data/template.csv", file)
}
}
shinyApp(ui = ui, server = server)
Where did I go wrong?我哪里做错了? Can someone help me make it work?
有人可以帮我让它工作吗? Thanks a lot!
非常感谢!
Please try the below:请尝试以下操作:
library(shiny)
ui <- fluidPage(
downloadButton("download", label = "Download")
)
server <- function(input,output) {
output$download <- downloadHandler(
filename <- function() {
"template_output.csv"
},
content <- function(file) {
file.copy("./data/template.csv", file)
}
)
}
shinyApp(ui = ui, server = server)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.