Your problem is that every time you press a button, you restore all the buttons (so the input is $ aX). And they are generated without a default value, so when you read them, they are all zeros.
For example, you can see your error if you suppress the loop in the output$selectInputs : (But now it allows you to set each aX only 1 time.)
output$selectInputs <- renderUI({ if(!is.null(input$obs)) print("w") w <- "" w <- paste(w, textInput(paste("a", input$obs, sep = ""), paste("a", input$obs, sep = ""))) HTML(w) })
Saving your code (and then saving the regeneration of all buttons), you must add to your argument the values โโof each textInput your "own value" (in fact, the value of the old input with the same identifier) value = input[[sprintf("a%d",i)]]
output$selectInputs <- renderUI({ w <- "" for(i in 1:input$obs) { w <- paste(w, textInput(paste("a", i, sep = ""), paste("a", i, sep = ""), value = input[[sprintf("a%d",i)]])) } HTML(w) })
Julien Navarre Mar 04 '14 at 10:29 2014-03-04 10:29
source share