title: for Loop - Replacement has length zero
body: <p>I have a little problem with a loop. Here is the code of the loop:</p>
  
  <pre><code>for (i in 1:length(input$count))
  {       
      id&lt;-paste("text",i)
      titles[i]&lt;-input$id
  }
  </code></pre>
  
  <p>This returns the following error</p>
  
  <blockquote>
    <p>Error in titles[i] &lt;- input$id : replacement has length zero</p>
  </blockquote>
  
  <p><strong>ui.R</strong></p>
  
  <pre><code>library(shiny)
  ui &lt;- fluidPage(
  numericInput("count", "Number of textboxes", 3),                  
  hr(),
  uiOutput("textboxes")
  )
  </code></pre>
  
  <p><strong>server.R</strong></p>
  
  <pre><code>server &lt;- function(input, output, session) {
     output$textboxes &lt;- renderUI({
     if (input$count == 0)
        return(NULL)
    lapply(1:input$count, function(i) {
        id &lt;- paste0("text", i)
        print(id)            // its prints the text1, text2,text3
        numericInput(id, NULL, value = abc)
        print(input$text1)   //it should print value abc , but it is not, why??
  
      })
    })
  }
  </code></pre>