pbapply | Adding progress bar to ' * apply ' functions in R | Development Tools library
kandi X-RAY | pbapply Summary
kandi X-RAY | pbapply Summary
A lightweight package that adds progress bar to vectorized R functions (*apply). The implementation can easily be added to functions where showing the progress is useful (e.g. bootstrap). The type and style of the progress bar (with percentages or remaining time) can be set through options. The package supports several parallel processing backends, such as snow-type clusters and multicore-type forking (see overview here).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of pbapply
pbapply Key Features
pbapply Examples and Code Snippets
Community Discussions
Trending Discussions on pbapply
QUESTION
I have a function that I'd like to apply to a large numeric vector:
...ANSWER
Answered 2020-Dec-24 at 15:39It looks walk
is running the same code 100 times. I think for each step in that 100 it is producing results2
again.
In the below not_purrr
is how I think it could be done with 100 breakpoints setup before the loop
QUESTION
The simplest way I've found so far to use a parallel lapply
in R was through the following example code:
ANSWER
Answered 2020-Jul-15 at 14:08QUESTION
I use pblapply() to run code in parallel. It gives a progression bar, which is useful. I use function like clusterExport() or clusterEvalQ() to export objects or librairies into clusters. But I didn't manage to share a home-made function, available in my environment. Can you help me with this ?
Here is an very basic example:
...ANSWER
Answered 2020-May-06 at 18:09A function is an object as well.
You can therefore export it using parallel::clusterExport(cl, "mean_by_column")
.
QUESTION
I am trying to write a function which has a parallel computation option.
To make it work in both windows, and mac or Linux environments, I am using a PSOCK system, which I believe is a default configuration in makeCluster()
. My question is whether I should, or it is more desirable, to pass all arguments to the clusters using a clusterExport
function. If I do this, I think I need to evaluate all input arguments-- instead of the default lazy evaluation. If some variables are used only in some special cases, this does not seem desirable.
For example, in the following code, I am wondering whether I should add
clusterExport(varlist = c("a","b","c"),cl = cl,envir = environment())
in the function. The following code works fine in my computer, but a similar code failed in other's computer.
I would be very interested to hear about the best practice as well. Thank you!
...ANSWER
Answered 2020-Apr-09 at 08:03You could try to set defaults to NULL
and do a case handling using sapply
. I'm not sure, though, if this really works, because I can't reproduce your error.
QUESTION
I have N tasks which I wish to parallelize across M cores in R. These tasks vary significantly in how long they will take to perform. Fortunately, I have a rough indication of which tasks are going to be slow and which are going to be fast. I also have a progress bar which increments by the number of tasks completed.
I want to optimise the order of the tasks such that:
- Total computation time is minimised
- The progress bar is representative of the time remaining, not the tasks remaining.
To give a more practical example:
...ANSWER
Answered 2019-Nov-13 at 16:58Futher research found this
Which suggests that the load balancing in pbapply is poor. They give an example which I have adapted
QUESTION
The makeCluster function sometimes hangs in my code and just needs to be rerun to fix the issue.
In order to do that in my code I'm trying to use a while loop plus the withTimeout function to have the makeCluster function timeout if it is hanging and rerun itself.
The issue is that when I create my cluster with withTimeout I can't access it later for my parallel lapply.
...ANSWER
Answered 2019-Oct-14 at 17:38When the envir
argument of withTimeout()
is not set, the clusters are created in .GlobalEnv
and everything works as expected.
QUESTION
I am trying to use OMBP
API in R but not able to use it properly
ANSWER
Answered 2019-Aug-01 at 12:12library(ombdapi)
is missing. Put it after library(pbapply)
.
You've installed it, so it's available for use, i.e. it's on the hard drive in a place R knows to look if someone tells R to load the code. Which is what the library()
call does.
QUESTION
I would like to monitor the progress of my mapply function. The data consists of 2 lists and there is a function with 2 arguments.
If I do something similar with a function that takes 1 arguments I can use ldply instead of lapply. (I'd like to rbind.fill the output to a data.frame)
If I want to do the same with mdply it doesn't work as the function in mdply wants values taken from columns of a data frame or array. Mapply takes lists as input.
These plyr apply functions are handy, not just because I can get the output as a data.frame but also because I can use the progress bar.
I know there is the pbapply package but that there is no mapply version and there is the txtProgressBar function but I could not figure out how to use this with mapply.
I tried to create a reproducible example (takes around 30 s to run)
I guess bad example. My l1 is a list of scraped websites (rvest::read_html) which I cannot send as a data frame to mdply. The lists really need to be lists.
...ANSWER
Answered 2017-Aug-14 at 13:15From ?mdply
I dare say you can't specify two data-inputs. Your error message means mdply
is trying to use l2
as function but a list cannot be coerced into a function...
The following works fine
QUESTION
I have written the ggstatsplot
package to carry out some statistical analysis. The package functions (in the development version) can either return a plot
or a call
that contains statistical details displayed in the subtitle of the plot.
Here is an example of a plot
as a return:
ANSWER
Answered 2019-Jun-13 at 16:16It is pretty easy to convert your example to Markdown code. This is nowhere near general, but it is kind of obvious how to extend it to handle other expressions.
The idea is to evaluate the plotmath
expression to form a string that is Markdown. For example, use this function:
QUESTION
I have this code where I want to sum the columns of a matrix.
I also want to have a couple of features (my matrix is much bigger than the example below):
- use multiple cores
- have a progress bar
I tried pbapply
from the pbapply package but without luck. My code is:
ANSWER
Answered 2017-Jun-09 at 06:33pbapply
doesn't take the cl
argument, so no. You can, however, convert your matrix to a data.frame (if that's feasible), and use sapply which should work on columns.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pbapply
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page