Re: [R] how to speed up this for loop?

2008-07-22 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Nordlund, > Dan (DSHS/RDA) > Sent: Tuesday, July 22, 2008 10:31 AM > To: r-help@r-project.org > Subject: Re: [R] how to speed up this for loop? > > > -Original

Re: [R] how to speed up this for loop?

2008-07-22 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Rheannon > Sent: Tuesday, July 22, 2008 9:09 AM > To: r-help@r-project.org > Subject: Re: [R] how to speed up this for loop? > > > Here is the full code: > > R <

Re: [R] how to speed up this for loop?

2008-07-22 Thread Rheannon
Here is the full code: R <- 5328 #Temp is a temperature file with daily temp. values for each day of the year, for 5328 locations Temp <- rnorm(100) dim(Temp) <- c(365,5328) # transpose temp dataframe in order to perform rollmean (running mean) on proper data section Temp_T <- t(Temp) library(zoo

[R] how to speed up this for loop?

2008-07-22 Thread Rheannon
Could anyone tell me a better way to achieve the output of this for loop? It seems to run quite slow. I'm sure there must be a more consise way to sum from FN to LN, excluding positive values, for each row. #sum between FN and LN, excluding positive values for(i in 1:R){ for(j in FN[i]:LN[i]){ if

Re: [R] how to speed up this for loop?

2008-07-22 Thread bartjoosen
I'm not sure if I understand correct, but maybe something like: apply(dat,2,function(x) sum(x[x<0])) Please do read the posting guide and post a small, working example!!! Bart Rheannon wrote: > > Could anyone tell me a better way to achieve the output of this for loop? > It seems to run quit