Note that there are some explanatory texts on larger screens.

plurals
  1. POLoop for matrices multiplication
    text
    copied!<p>I have this matrix:</p> <pre><code> V1 V2 V3 V4 V5 V6 V7 V8 [1,] 0.8399983 0.01558029 0.00000000 0.0000000 0.00000000 0.00000000 0.00000000 0 [2,] 0.0000000 0.89022017 0.02570281 0.0000000 0.00000000 0.00000000 0.00000000 0 [3,] 0.0000000 0.00000000 0.87910624 0.0242963 0.00000000 0.00000000 0.00000000 0 [4,] 0.0000000 0.00000000 0.00000000 0.0000000 0.03428571 0.00000000 0.00000000 0 [5,] 0.0000000 0.00000000 0.00000000 0.0000000 0.00000000 0.02988506 0.00000000 0 [6,] 0.0000000 0.00000000 0.00000000 0.0000000 0.00000000 0.73438228 0.01666667 0 [7,] 0.0000000 0.00000000 0.00000000 0.0000000 0.00000000 0.00000000 0.00000000 0 [8,] 0.0000000 0.00000000 0.00000000 0.0000000 0.00000000 0.00000000 0.00000000 0 </code></pre> <p>And this vector:</p> <pre><code> [,1] [1,] 908 [2,] 516 [3,] 269 [4,] 85 [5,] 32 [6,] 13 [7,] 2 [8,] 3 </code></pre> <p>And I am trying to come up with a loop that will keep multiplicating the results (new vectors) by the same matrix (it is a simple exemple of population matrices model). I need all the results from the 1st multiplication, until 100th, so I can put them into a graph. Any ideas?</p> <pre><code>&gt; dput(mat) structure(c(0.8399983, 0, 0, 0, 0, 0, 0, 0, 0.01558029, 0.89022017, 0, 0, 0, 0, 0, 0, 0, 0.02570281, 0.87910624, 0, 0, 0, 0, 0, 0, 0, 0.0242963, 0, 0, 0, 0, 0, 0, 0, 0, 0.03428571, 0, 0, 0, 0, 0, 0, 0, 0, 0.02988506, 0.73438228, 0, 0, 0, 0, 0, 0, 0, 0.01666667, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), .Dim = c(8L, 8L), .Dimnames = list( c("[1,]", "[2,]", "[3,]", "[4,]", "[5,]", "[6,]", "[7,]", "[8,]"), c("V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8" ))) &gt; dput(vec) structure(c(908L, 516L, 269L, 85L, 32L, 13L, 2L, 3L), .Dim = c(8L, 1L), .Dimnames = list(c("[1,]", "[2,]", "[3,]", "[4,]", "[5,]", "[6,]", "[7,]", "[8,]"), "X..1.")) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload