title: R adding values to vector in for loop
body: <p>I'm working in R &amp; using a for loop to iterate through my data:</p>
  
  <pre><code>pos = c(1256:1301,6542:6598)
  sd_all = null
  
  
  for (i in pos){
      nameA = paste("A", i, sep = "_")
      nameC = paste("C", i, sep = "_")
      resA = assign(nameA, unlist(lapply(files, function(x) x$percentageA[x$position==i])))
      resC = assign(nameC, unlist(lapply(files, function(x) x$percentageC[x$position==i])))
      sd_A = sd(resA)
      sd_C = sd(resC)
      sd_all = ?
  }
  </code></pre>
  
  <p>now I want to generate a vector called 'sd_all' that contains the standard deviations of resA &amp; resC. I cannot just do 'sd_all = c(sd(resA), sd(resC))', because then I only use one value in 'pos'. I want to do it for all values in 'pos' off course.</p>