Re: [R] how to get rid of 2 for-loops and optimize runtime

2009-10-20 Thread William Dunlap
> -Original Message- > From: Ian Willems [mailto:ian.will...@uz.kuleuven.ac.be] > Sent: Tuesday, October 20, 2009 6:46 AM > To: William Dunlap; r-help@r-project.org > Subject: RE: [R] how to get rid of 2 for-loops and optimize runtime > > Hi William, > > Your

Re: [R] how to get rid of 2 for-loops and optimize runtime

2009-10-20 Thread Ian Willems
erent rows? Thank u for your help regards, Ian -Oorspronkelijk bericht- Van: William Dunlap [mailto:wdun...@tibco.com] Verzonden: maandag 19 oktober 2009 18:08 Aan: Ian Willems; r-help@r-project.org Onderwerp: RE: [R] how to get rid of 2 for-loops and optimize runtime > -Original

Re: [R] how to get rid of 2 for-loops and optimize runtime

2009-10-20 Thread Ian Willems
nk u for your time Greetings, Ian -Oorspronkelijk bericht- Van: joris meys [mailto:jorism...@gmail.com] Verzonden: maandag 19 oktober 2009 16:12 Aan: Ian Willems CC: r-help@r-project.org Onderwerp: Re: [R] how to get rid of 2 for-loops and optimize runtime Hi Ian, first of all, take

Re: [R] how to get rid of 2 for-loops and optimize runtime

2009-10-19 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Ian Willems > Sent: Monday, October 19, 2009 6:50 AM > To: 'r-help@r-project.org' > Subject: [R] how to get rid of 2 for-loops and optimize runtim

Re: [R] how to get rid of 2 for-loops and optimize runtime

2009-10-19 Thread joris meys
Hi Ian, first of all, take a look at the functions sapply, mapply, lapply, tapply, ... : they are the more efficient way of implementing loops. Second, could you elaborate a bit further on the data set : the amount of the month ago, is that one value from another row, or the sum of all values in

[R] how to get rid of 2 for-loops and optimize runtime

2009-10-19 Thread Ian Willems
Short: get rid of the loops I use and optimize runtime Dear all, I want to calculate for each row the amount of the month ago. I use a matrix with 2100 rows and 22 colums (which is still a very small matrix. nrows of other matrixes can easily be more then 10) Table before Year month quart