Re: [R] Matrix multiplication and random numbers

2009-09-11 Thread RFish
Hi Sorry I don't seem to have explained what I'm trying to do very clearly. The piece of code below multiplies the two matrices together a number of times based on the value in the matmult(InitialPop,1) term in this case one (year), this gives me the end population for the analysis.

Re: [R] Matrix multiplication and random numbers

2009-09-11 Thread Henrique Dallazuanna
If I understand you can use replicate: replicate(10, matmult(InitialPop, 1)) On Fri, Sep 11, 2009 at 1:11 PM, RFish tomworthing...@talk21.com wrote: Hi Sorry I don't seem to have explained what I'm trying to do very clearly. The piece of code below multiplies the two matrices together a

[R] Matrix multiplication and random numbers

2009-09-09 Thread RFish
Dear All I new to using R and am struggling with some matrix multiplication. I have two matrices, one containing random numbers, these are multiplied together to get another matrix which is different each time. When I put in another for loop to repeat this process a multiple times the matrices

Re: [R] Matrix multiplication and random numbers

2009-09-09 Thread jim holtman
I am not sure what you mean by being the same each time. If I make successive calls to the function, I get different results: z [,1] [1,] 0. [2,] 0. [3,] 201.6382 [4,] 0. [5,] 0. [6,] 0. [7,] 0. matmult(InitialPop,1) [,1] [1,] 0.000 [2,]

Re: [R] Matrix multiplication and random numbers

2009-09-09 Thread Chris Stubben
RFish wrote: I new to using R and am struggling with some matrix multiplication. I'm not sure what you're trying to print, but you could place this vector in an expression

Re: [R] Matrix multiplication and random numbers

2009-09-09 Thread RFish
Sorry I probably wasn't clear with my description. The reason i put for loop in was that I want to do the matrix multiplication about 1000 times to get a 1000 different matrices. Therefore I was hoping the for loop would be able to automate this then use write.table to write to an external