-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functions to add progress bars to for loops and apply functions #27
Comments
+1! |
Thanks. I am not completely satisfied with the syntax and the |
A few alternatives:
|
Alternative syntax ideas: ## This needs NSE to get `x`
progress > for (i in x) { }
## This knows `x` right away, no NSE needed
progress(x) > for (i in x) { }
## Similarly with *apply:
progress > lapply(x, function(i) { }) Maybe this is stupid, but how about ooo == for (i in x) { }
ooo == lapply(x, function(i) {}) EDIT: this one also parses: ---O- for (i in x) { }
---O- lapply(x, function(i) {} EDIT: with some hacks, even this seems possible: for (i in progress(x)) { }
lapply(progress(x), function(i) { }) |
So we need to go with sg clumsier, e.g. progress %P% for (i in 1:10) { print(i) }
P%P% for (i in 1:10) { print(i) } add %[=]% for (i in 1:10) { print(i) } Or the magical progress := for (i in 1:10) { print(i) } But the So I guess it has to be progress %% for (i in 1:10) { print(i) }
progress %% lapply(1:10, print) |
These look good to me. I haven't looked at the details at all, but would it be possible to use a pipe, perhaps like:
|
This is not valid R syntax, I am afraid. It does not parse.
This is probably possible, but I would need to redefine |
Looks like |
Can you make a unary operator
|
That's not possible, unfortunately. I could use |
Work is going on in the https://github.com/gaborcsardi/progress/tree/decorator branch now. |
A relevant discussion: tidyverse/purrr#149 I quite like the functional form: progressify(lapply)(seq, fun) and maybe this does not even require NSE. We just create a new function that calls both the original function and But this does not work for for (i in progressify(seq)) { } could work. It requires some tricks, though. Maybe we can just wait until the iterator type |
I assume y'all are aware of this: https://github.com/psolymos/pbapply ? I am using it and it works great for apply functions. Still no solution for parallel functions or |
@kendonB I have probably seen it, I am not sure to be honest. |
Just uploaded pbapply v1.3-0 to CRAN with parallel functionality. |
Implemented in cli. |
E.g.
and
Implementation is easy. The
for
loops need some non-standard evaluation.The text was updated successfully, but these errors were encountered: