pbapply()

[This article was first published on Analyst At Large » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In my previous post, I wrote about displaying a Windows progress bar (useful when going through long for-loops).  In the comments, a couple of users recommended that I check out pbapply().  This function is great too (and works on all platforms)!  Basically, it allows you to perform all the apply() functions – apply(), lapply(), sapply(), etc. and adds in a progress bar.  Here is some code showing a very simple example:

###### Packages
library(pbapply)
 
###### Data
n<-1000
mat<-matrix(rnorm(n),ncol=10,nrow=100)
 
###### apply() vs pbapply()
x<-pbapply(mat,1,sum)
y<-apply(mat,1,sum)
 
x-y

To leave a comment for the author, please follow the link and comment on their blog: Analyst At Large » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)