Create a new vector every loop iteration in R -
I have the following problem: I have a for-loop => (in i:20) { T & LT; - C (T, print (I: 20))} ...
I know how to save all the results in a vector, but I want to save the result every Vector as its own vector (as you see it above) => so that for example t [18]
only 18920 and t [20]
only 20 That is, I thought about a matrix, but each line should end with "20" and the rest would be filled with "0" in 20x20 matrix.
How about a list for that purpose:
lst & lt; - List () for (i 1:20) {lst [[i]] & lt; - i: 20}
then receive it by calling
lst [[18]] # [1] 1819
Comments
Post a Comment