如何在rshiny中以.csv格式下载已编辑的数据帧?
我正在开发一个Rshiny应用程序,其中我编辑了数据帧的内容,并以.csv格式下载了编辑后的数据帧。但下载的文件不是.csv格式。有人能帮我解决这个问题吗如何在rshiny中以.csv格式下载已编辑的数据帧?,r,shiny,R,Shiny,我正在开发一个Rshiny应用程序,其中我编辑了数据帧的内容,并以.csv格式下载了编辑后的数据帧。但下载的文件不是.csv格式。有人能帮我解决这个问题吗 output$downloadData <- downloadHandler(filename = function() {paste(Sys.time(), 'Edited Table.csv', sep='') } ,content = function(file) {write.csv(sample_data(), file,
output$downloadData <- downloadHandler(filename = function() {paste(Sys.time(), 'Edited Table.csv', sep='') } ,content = function(file) {write.csv(sample_data(), file, row.names = FALSE)})
output$downloadData我试图用一个例子来复制您的结果,但无法复制您的问题。这是一个自给自足的RShiny应用程序,可以下载.csv文件。请确保您的应用程序遵循此模板,如果问题仍然存在,请提供相同的可复制示例
library(shiny)
ui <- fluidPage(
downloadButton("downloadData", "Download")
)
server <- function(input, output) {
# Your Sample dataset
sample_data <- reactive({mtcars})
output$downloadData <- downloadHandler(
filename = function() {
paste(Sys.time(), ' Edited Table.csv', sep='')
},
content = function(file) {
write.csv(sample_data(), file, row.names = FALSE)
}
)
}
shinyApp(ui, server)
库(闪亮)
ui通过使用上述代码,它以.file格式下载数据帧,并且可以使用记事本、Word等进行查看,但我需要以.csv格式下载。清楚吗?我不认为问题与代码有关。确保已安装Microsoft Excel,并为扩展名为.xlsx、.xlsx、.csv的文件创建默认程序,以MS Excel的形式打开文件。下面是一个链接,供您参考如何在windows中设置默认选项