[R] filling list of data frames
Jim Holtman
jholtman at gmail.com
Thu Jun 27 11:57:20 CEST 2013
You might want to use Rprof to profile your code to understand where the time is going; it might be in the function you are callingband therefore the "for" loop might not be the issue.
Sent from my iPad
On Jun 27, 2013, at 4:19, "Frederico Mestre" <mestre.frederico at gmail.com> wrote:
> Hello:
>
>
>
> I have a list of data frames, built like this: the second df is a result of
> a function applied to the first, and so on.
>
>
>
> So the ith df is always dependent on the (i-1)th df. I've been doing this
> using for loops. However I think I have too many for loops which is making
> my code run slowly.
>
>
>
> Is there any workaround this? How can I avoid the use of for loops?
>
>
>
> As an example:
>
>
>
> output.list <- as.list(rep("", 100))#creation of a list
>
>
>
> output.list[[1]] <- df1#first position
>
>
>
>
>
> for(I in 2:100){#following positions
>
>
>
> df0 <- output.list[[i-1]]
>
>
>
> df0_1 <- f1(df0)#function applied to the previous df
>
>
>
> output.list[[i]] <- df0_1#new df
>
>
>
> }
>
>
>
> thanks,
>
>
>
> Frederico
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list