title: how to fill up NA entries in the vector generated with assign command?
body: <p>I would like to generate series of vectors like india_a, india_b, india_c. These vectors will have length 3. For example, 1st entry in india_a will be summation of 'total'when yrs=1 and crs=a. </p>
  
  <pre><code>for (i in crimes){   assign(paste("india_",i,sep=""),rep(NA,12))   
  for (j in 1:12){
      india_i[j] &lt;-sum(juvenile_crime$total[
                    juvenile_crime$year==years[j]&amp;juvenile_crime$crime==crimes[i]]) } }
  </code></pre>
  
  <p>this is the message I get when I run above code</p>
  
  <pre><code>Error in india_i[j] &lt;- sum(juvenile_crime$total[juvenile_crime$year == :
  object 'india_i' not found
  </code></pre>
  
  <p>this example might help: </p>
  
  <pre><code>sts &lt;- c(rep("s1",9),rep("s2",9))
  yrs &lt;- c(1,1,1,2,2,2,3,3,3,1,1,1,2,2,2,3,3,3)
  crs &lt;- c("a","b","c","a","b","c","a","b","c")
  total &lt;- c(1:18)
  cri &lt;- data.frame(sts,yrs,crs,total)
  attach(cri)
  yr &lt;- levels(cri$yrs)
  cr &lt;- levels(cri$crs)
  for (i in crs){   
  assign(paste("india_",i,sep=""),rep(NA,3))   
  for (j in 1:3){
  india_i[j] &lt;-sum(total[yrs==yr[j]&amp;crs==cr[i]]
  }
  }
  </code></pre>