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:

  1. "infile" , "archive" vars had inside "observe({})" statement.
  2. in order ve visible downloadhandler, archive must assigned "<<-" operator, not "<-", in order global var.

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -