Hi I'm trying to speed my loop up. Any Suggestions?? At the moment it takes a
few days to run.

THE CODE
---------------------------------------------------------------------------------------------------
        for(i in 1:11) {
                for (j in 3:12) {
                        for (k in 1:273107) {                                   
                                                y[k,1] <- x[i,j,k]
                                                print(y)
                                                                
Rainfall_dataset <- read.table("1km_grid_nzmg.csv", 
                                                                header=TRUE, 
sep=",", na.strings="NA", dec=".", strip.white=TRUE)       

                                                                t <- 
Rainfall_dataset
                                                                print(t)
                                                                
                                                                p<-cbind(t,y)
                                                                #y<-cbind(t,y)
                                                                #print(y)       
                
                        }
                                                # This where you write out 
array y to a csv file
                                                # Save output as a csv file     
                                                site <- paste("site",i,"-",j)

                                                        csvfile <- 
paste(site,sep=".","csv"); print(csvfile)
                                                        path<- 
paste("c:/Data/",csvfile)
                                                        print(path)
                                                        write.csv(p,file=path, 
row.names = TRUE)                
                }
        }

--
View this message in context: 
http://r.789695.n4.nabble.com/Speeding-nested-loops-up-tp3751485p3751485.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to