On Sun, Mar 22, 2009 at 5:06 PM, Blanchette, Marco <m...@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.

install.packages("plyr")
library(plyr)

myResults <- llply(aList, myFnc, .progress = "text")

see http://had.co.nz/plyr for more info.

Hadley


-- 
http://had.co.nz/

______________________________________________
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