r - Shiny reactive scan of archive, then write() it to download, fails in cat() -> argument type "closure" not handled -
i wanted upload file, change in way , download lines changed. write() function can't replaced code.
there summarized code:
shinyserver(function(input, output) { infile <- reactive({input$file}) archive <- reactive({scan(infile$datapath, = character(), skip = 1, sep= "\n")}) output$downloaddata <- downloadhandler( filename = function() { paste("something", '.cfg', sep='') }, content = function(file) { write(archive, file) } ) })
>
shinyui(fluidpage( fileinput("file", label="something: "), downloadbutton('downloaddata', 'download') ))
it throws me error when try dowload file uploaded:
error in cat(list(...), file, sep, fill, labels, append) : argument 1 (type 'closure') not handled 'cat'
thank you
edit: tried omitting reactive() function when assigning "archive", tells me infile$datapath : object type "closure" not subset, , tried assigning "as.character(reactive(scan ...))" archive doesnt work.
realized there 2 problems:
- "infile" , "archive" vars had inside "observe({})" statement.
- in order ve visible downloadhandler, archive must assigned "<<-" operator, not "<-", in order global var.
Comments
Post a Comment