pbapply()

August 29, 2014
By

(This article was first published on Analyst At Large » R, and kindly contributed to R-bloggers)

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 on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Sponsors

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)