title: How to assign values to row of a matrix when matrix name is a character string
body: <p>I want to create several matrixes and assign values which are obtained through the function to the specific rows automatically. I'll give example of what I've tried so far:</p>
  
  <pre><code>EXAMPLE1&lt;-matrix(ncol=4, nrow=16)
  EXAMPLE2&lt;-matrix(ncol=4, nrow=16)
  EXAMPLE3&lt;-matrix(ncol=4, nrow=16)
  EXAMPLE4&lt;-matrix(ncol=4, nrow=16)
  
  
  for(i in 1:16){
    for(j in 1:4){
      paste0("EXAMPLE",j, "[",i,",","]")&lt;- c(1:4)
    }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>for(i in 1:16){
    for(j in 1:4){
      get(paste0("EXAMPLE",j)[i,]&lt;- c(1:4)
    }
  }
  </code></pre>
  
  <p>but <i> "target of assignment expands to non-language object"</i> is returned. So I tried</p>
  
  <pre><code>for(i in 1:16){
    for(j in 1:4){
      assign(paste0("EXAMPLE",j, "[",i,",","]"), c(1:4))
    }
  }
  </code></pre>
  
  <p>This does not return error, but values are not written into matrix. </p>
  
  <p><em>At first matrixes are empty</em></p>
  
  <pre><code>     [,1] [,2] [,3] [,4]
  [1,]   NA   NA   NA   NA
  [2,]   NA   NA   NA   NA
  [3,]   NA   NA   NA   NA
  [4,]   NA   NA   NA   NA
  </code></pre>
  
  <p><em>and after one loop is performed (i=1) I expext all EXAMPLE matrixes to have 1 row filled (and after second - second row filled, so that when loop ends I would have EXAMPLE matrix full of numbers.).</em></p>
  
  <pre><code>     [,1] [,2] [,3] [,4]
  [1,]    1    2    3    4
  [2,]   NA   NA   NA   NA
  [3,]   NA   NA   NA   NA
  [4,]   NA   NA   NA   NA
  </code></pre>
  
  <p>The point is though, i do not how to assign value to the matrix row, because I pass matrix name by paste function. How to assign values to a specific row in a matrix if I want to put its name as character string? Any help would be wonderful. Thanks</p>
  
  <p>...Edition...
  I am sorry that I am not very clear. As I mentioned, I want to write result of a function (which happens to have same number of columns as my matrix) into matrix row. Each row would take result from function applied to different observation. I want to apply several functions to same variable so I have several matrixes for results of the different function (which differ in column numbers and have different names). The way I numbered and named matrixes is the easiest to keep track of results and later compare them. Above I gave just an example of problem which is that I cannot assign value to a row of matrix because I give name of matrix as string (and I do that because otherwise there would be quite a lot of numbering to do). So in general I want to be able to do</p>
  
  <pre><code>EXAMPLEj[i,]&lt;-SomeFunctionResult
  </code></pre>
  
  <p>Where j goes 1 to 10 or some other numbers</p>
  
  <p>Thats why I use loop and <code>paste0("EXAMPLE", j)</code> to generate names of matrixes and i to denote which observation for function to use and in which row to put the result. Matrixes are already created, but I found no way to pass results to row of the matrix.</p>
  
  <p>I am new at R (and programming) so it is possible I've chosen the worst way possible to solve this and that list or arrays would be much easier to use. Thank you for your responses.</p>