I am trying to download a dtaframe as csv file but when I press download button, I come up with an html file. Could you please help me to download a csv file? My code is below
output$clean_download <- downloadHandler(
filename = function() {
paste('clean_data.csv', sep='')
},
# content is a function with argument file. content writes the plot to the device
content = function(filename) {
write.csv(as.data.frame(train_cleaned()), filename, row.names=FALSE)
}
)
I expect that happens when the above struggle.
What is train_cleaned() before you cast it to a data.frame ?
You can peek at your objects in the console, a tradition as old as programming :
I tried using write.csv(train_cleaned) outside of shiny and it worked properly, however when I try to use it with downloadHandler, a HTML file is downloaded instead of csv file.