Re: [R] [External] Re: Speeding up a loop

2012-07-24 Thread Rui Barradas
Hello, Anyway, I've redid part of the function in order to accomodate 1. larger increments and 2. keep if equal or not. So, here's the complete version and forget my two previous mails. to.keep <- function(x, increment = 1e4, keep.if.equal = FALSE){ keep <- function(i, env){ env$i

Re: [R] [External] Re: Speeding up a loop

2012-07-24 Thread Rui Barradas
Hello, Sorry for the mess, the logical operation should also be changed to conjunction: no <- x[i, 1] <= a1 & x[i, 2] <= a2 & x[i, 3] >= a3 & x[i, 4] <= a4 Rui Barradas Em 24-07-2012 13:09, Rui Barradas escreveu: Hello, Are you sure? With a matirx composed of those two rows only I

Re: [R] [External] Re: Speeding up a loop

2012-07-24 Thread Rui Barradas
Hello, Are you sure? With a matirx composed of those two rows only I had a problem, the function to.keep() returned NULL. See the changes made to avoid it. # beginning of loop for(i in seq_len(nrow(x))){ #yes <- x[i, 1] > a1 | x[i, 2] > a2 | x[i, 3] < a3 | x[i, 4] > a4 #if

Re: [R] [External] Re: Speeding up a loop

2012-07-20 Thread Jean V Adams
"Reith, William [USA]" wrote on 07/20/2012 09:52:02 AM: > Would this matrix eat up memory making the rest of my program > slower? Each x needs to be multiplied by a matrix and the results > checked against a set of thresholds. Doing them one at a time takes > at least 24 hours right now. >