[R] Following progress in a lapply() function

Gabor Grothendieck ggrothendieck at gmail.com
Sun Mar 22 23:14:17 CET 2009


There are several packages with progress bars:

RSiteSearch("progress")

On Sun, Mar 22, 2009 at 6:06 PM, Blanchette, Marco <MAB at stowers.org> wrote:
> Dear all,
>
> I am processing a very long and complicated list using lapply through a custom function and I would like to generate some sort of progress report. For instance, print a dot on the screen every time 1000 item have been process. Or even better, reporting the percent of the list that have been process every 10%. However, I can't seem to figure out a way to achieve that.
>
> For instance, I have a list of 50,000 slots:
>
> aList <- replicate(50000,list(rnorm(50)))
>
> That need to be process through the following custom function:
>
> myFnc <- function(x){
>     tTest <- t.test(x)
>    return(list(p.value=tTest$p.value,t.stat=tTest$stat))
> }
>
> Using an lapply statement, as in:
>
> myResults <- lapply(aList, myFnc)
>
> The goal would be to report on the progress of the lapply() function during processing.
>
> Any suggestion would be greatly appreciated.
>
> Thanks
>
> Marco
>
>
> --
> Marco Blanchette, Ph.D.
> Assistant Investigator
> Stowers Institute for Medical Research
> 1000 East 50th St.
>
> Kansas City, MO 64110
>
> Tel: 816-926-4071
> Cell: 816-726-8419
> Fax: 816-926-2018
>
> ______________________________________________
> 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