title: Is there a way to make a for loop that will get one element of the data in every iteration and create a vector at the end of all the elements
body: <p>I have a sql database with ID's and info, I want to loop through the database and only get info for certain IDs, I want to get an element of every info of every ID in the database and store it into a vector. </p>
  
  <p>I have tried a for loop, but get only the ID numbers. </p>
  
  <pre class="lang-r prettyprint-override"><code>a &lt;-c()
  for (i in IDs){
  
    x &lt;- dbGetQuery(mydb, paste('SELECT * FROM  table WHERE Person = ', i, ';'))
    info = fromJSON(x$info)
  
    ind &lt;- as.data.frame(info$x)
    int &lt;- as.data.frame(info$y)
    inx &lt;- as.data.frame(info$z)
  
    a[i] &lt;- inx[,5][1]
  }
  </code></pre>
  
  <p>The expected output would be a vector of elements that correspond to the element that is in inx column 5 for every ID in the vector I'm iterating. So a vector of length of the IDs desired that contains one element for each ID.</p>