Re: [R] Large loops in R

2012-12-06 Thread Charles Novaes de Santana
Thank you all for your help! I used the function big.matrix, from a package named bigmemory, to allocate a large matrix 50k x 50k (http://www.inside-r.org/packages/cran/bigmemory/docs/bigmemory). And I followed the suggestions from Sarah to do the calculations fastly! Thank you very much!

[R] Large loops in R

2012-12-04 Thread Charles Novaes de Santana
Dear all, I need to access data from a large matrix (48000 x 48000) and to do it I am trying to run two loops using for command. Surely it is been a very slow job. I heard that for is not the best option to perform large loops in R, but I don't really know what would be the best (fast) option

Re: [R] Large loops in R

2012-12-04 Thread R. Michael Weylandt michael.weyla...@gmail.com
option to perform large loops in R, but I don't really know what would be the best (fast) option. sapply? vapply? Could anyone help me with this issue, please? What exactly are you trying to do? It's likely doable with a few vectorized operations. Michael Thank you very much for your

Re: [R] Large loops in R

2012-12-04 Thread Charles Novaes de Santana
) and to do it I am trying to run two loops using for command. Surely it is been a very slow job. I heard that for is not the best option to perform large loops in R, but I don't really know what would be the best (fast) option. sapply? vapply? Could anyone help me with this issue, please? What

Re: [R] Large loops in R

2012-12-04 Thread Sarah Goslee
: Dear all, I need to access data from a large matrix (48000 x 48000) and to do it I am trying to run two loops using for command. Surely it is been a very slow job. I heard that for is not the best option to perform large loops in R, but I don't really know what would be the best (fast

Re: [R] Large loops in R

2012-12-04 Thread Peter Langfelder
On Tue, Dec 4, 2012 at 11:27 AM, Charles Novaes de Santana charles.sant...@gmail.com wrote: Dear Michael, Thank you for your answer. I have 2 matrices. Each position of the matrices is a weight. And I need to calculate the following sum of differences: Considering: mat1 and mat2 - two

Re: [R] Large loops in R

2012-12-04 Thread Charles Novaes de Santana
On Tue, Dec 4, 2012 at 8:43 PM, Peter Langfelder peter.langfel...@gmail.com wrote: On Tue, Dec 4, 2012 at 11:27 AM, Charles Novaes de Santana charles.sant...@gmail.com wrote: Dear Michael, Thank you for your answer. I have 2 matrices. Each position of the matrices is a weight. And I need

Re: [R] Large loops in R

2012-12-04 Thread Charles Novaes de Santana
) and to do it I am trying to run two loops using for command. Surely it is been a very slow job. I heard that for is not the best option to perform large loops in R, but I don't really know what would be the best (fast) option. sapply? vapply? Could anyone help me with this issue, please? What

Re: [R] Large loops in R

2012-12-04 Thread R. Michael Weylandt
On Tue, Dec 4, 2012 at 8:14 PM, Charles Novaes de Santana charles.sant...@gmail.com wrote: Error in matrix(0, 48000, 48000) : too many elements specified but I thought it was a machine limitation (and I was asking for access to a better machine in my labs...). Thanks for clarifying it. Well,

Re: [R] Large loops in R

2012-12-04 Thread Sarah Goslee
I don't think there's any reason for the calculation you're doing that you must have the whole matrix in memory, is there? Unless there's something more than what you've shown us, you're just taking the sum of elementwise operations. You can read the matrix in in manageable chunks, take the sum

Re: [R] Large loops in R

2012-12-04 Thread arun
Subject: Re: [R] Large loops in R Dear Michael, Thank you for your answer. I have 2 matrices. Each position of the matrices is a weight. And I need to calculate the following sum of differences: Considering: mat1 and mat2 - two matrices (each of them 48000 x 48000). d1 and d2 - two constant