title: Loop in R: how to save the outputs?
body: <p>I am trying to save the data from a loop of logical tests.</p>
  
  <p>So I have the following data:</p>
  
  <pre><code>T1 &lt;- matrix(seq(from=100000, to=6600000,length.out=676),26,26) # a matrix of 26X26 - here with illustrive values
  
  minmax &lt;- seq(from=1,to=49,by=1) # creates a sequence
  Fstep &lt;- 6569141.82/minmax       # define a vector from 0 to 6569141.82 with 49 divisions
  F &lt;- rev(round(Fstep,0))         # round the vector values and re order them
  F
  </code></pre>
  
  <p>I have runned the following loop</p>
  
  <pre><code>for (i in 1:49) {
    print(T1 &gt; F[i]) # I used print to see the results in the screen
  }
  </code></pre>
  
  <p>This loop returns me 49 matrices filled in with logical values (True or false). Each matrix is the comparison of T1 against each of the 49 positions F[i] (F[1], ...., F[49])</p>
  
  <p>I need to have the values in those matrices for further using as adjacency matrices for network plots. However when I can't neither assign those logical values to an matrix, neither save them in csv values using "write.matrix". </p>
  
  <p>So, I need to have 49 - matrices "W" filled in with logical values (T or F). I already got those values by the loop above but I can't get it as an object or as collection of csv. files.</p>
  
  <p>I tried</p>
  
  <pre><code>W&lt;-matrix(0,26,26) #create an empty matrix to assign the logical arguments
  for (i in 1:49){
    W[i] &lt;- T1&gt;F[i] # I used print to see the results in the screen
  }
  </code></pre>
  
  <p>which returns the following warning</p>
  
  <pre><code>Warning messages:
  1: In W[i] &lt;- (T1 &gt; F[i]) :
    number of items to replace is not a multiple of replacement length
  </code></pre>
  
  <p>I also tried a different setting in which all the matrices I compare have the same dimensions. </p>
  
  <pre><code>create.M &lt;- function(F){ #  a function to transform  each position F[i] into a 26X26 matrix
    for (i in 1:49) {
      matrix(F[i],26,26)
    }
  }
  
  Loop.T1 &lt;- function(T1){ #  a function to replicate T1(49 times)
    for ( i in 1:49) {
      T1
    }
  }
  </code></pre>
  
  <p>and compared the two outputs</p>
  
  <pre><code>Loop.T1(T1)&gt;create.M(F)
  </code></pre>
  
  <p>which returns</p>
  
  <pre><code>logical(0)
  </code></pre>