【发布时间】:2017-08-23 06:42:45
【问题描述】:
当用户单击按钮时,我想将数据表输出写入 csv。我在 r 中为下载功能编写了以下代码
ui.r
tabItem(tabName = "output",
h2("Resource Predictions"),
fluidRow(
box(
width = 3, status = "info",solidHeader = TRUE,
title = "QC Assignment",
tableOutput("qc_assign")
),
box(
width = 9, status = "info",solidHeader = TRUE,
title = "ITV Assignment",
DT::dataTableOutput("itv_seq")
)),
fluidRow(
downloadButton("downloadtable", "Download ITV assignment file",style="display: block; margin: 0 auto; width: 230px;color: blue;"))
),
我的 server.r 文件如下所示
qc_assignment <- reactive({
.
.
.
list(ITV_assign = itv_assign)
})
output$downloadtable <- downloadHandler(
itv_seq <- qc_assignment()[['ITV_assign']],
filename = function() {paste("ITV_assignement_",input$ves_arrv_date,".csv",sep="")},
content = function(file){ write.csv(itv_seq, file) }
)
当我点击Download ITV assignment file 按钮时,文件浏览器打开,它正在保存名称为downloadtable 的文件,没有.csv 扩展名。
我做错了什么?
【问题讨论】: