### Basic SimDesign Simulation Setup Source: https://progressify.futureverse.org/articles/progressify-81-SimDesign.html This is a standard setup for a SimDesign simulation without progress reporting. It defines the design, generate, analyse, and summarise functions. ```r library(SimDesign) Design <- createDesign(factor1 = c(1, 2)) Generate <- function(condition, fixed_objects = NULL) rnorm(100) Analyse <- function(condition, dat, fixed_objects = NULL) mean(dat) Summarise <- function(condition, results, fixed_objects = NULL) mean(results) res <- runSimulation(design = Design, replications = 100, generate = Generate, analyse = Analyse, summarise = Summarise) ``` -------------------------------- ### Progressify with CRAN Packages Source: https://progressify.futureverse.org/index.html Examples of using progressify with functions from popular CRAN packages like boot, fwb, lme4, partykit, sandwich, and SimDesign. Ensure the respective packages are installed. ```R res <- boot::boot(data, statistic, R = 100) |> progressify() ``` ```R res <- fwb::fwb(data, statistic, R = 100) |> progressify() ``` ```R res <- lme4::bootMer(fit, statistic, nsim = 100) |> progressify() ``` ```R forest <- partykit::cforest(Survived ~ ., data = as.data.frame(Titanic), ntree = 50L) |> progressify() ``` ```R v <- sandwich::vcovBS(fit) |> progressify() ``` ```R res <- SimDesign::runSimulation(design, replications, generate, analyse, summarise) |> progressify() ``` -------------------------------- ### Basic boot() function usage Source: https://progressify.futureverse.org/articles/progressify-81-boot.html This is a standard example of using the boot() function from the boot package to calculate bootstrap replicates without progress reporting. It sets up data, a statistic function, and the number of replicates. ```R library(boot) x <- 1:100 my_stat <- function(data, i) mean(data[i]) res <- boot(data = x, statistic = my_stat, R = 1000) ``` -------------------------------- ### List supported functions for 'purrr' package (conditional) Source: https://progressify.futureverse.org/reference/progressify_supported_packages.html Demonstrates how to retrieve supported functions for the 'purrr' package, but only if the package is installed. This is a common pattern for safely accessing package-specific functionality. ```R if (requireNamespace("purrr")) { fcns <- progressify_supported_functions("purrr") print(fcns) } ``` -------------------------------- ### Basic Purrr Map with Progressify Source: https://progressify.futureverse.org/articles/progressify-21-purrr.html Demonstrates the core usage of progressify with purrr's map function. Ensure progressify and purrr are loaded, and handlers are set globally. This example emulates a slow function to visualize progress. ```R library(progressify) handlers(global = TRUE) library(purrr) slow_fcn <- function(x) { Sys.sleep(0.1) # emulate work x^2 } xs <- 1:100 ys <- xs |> map(slow_fcn) |> progressify() ``` -------------------------------- ### Basic cforest() Functionality Source: https://progressify.futureverse.org/articles/progressify-81-partykit.html This example demonstrates the basic usage of the 'cforest()' function from the 'partykit' package without progress reporting. It fits a random forest model to the Titanic dataset. ```R library(partykit) data("Titanic", package = "datasets") tt <- as.data.frame(Titanic) forest <- cforest(Survived ~ ., data = tt, ntree = 50L) ``` -------------------------------- ### Add progress reporting to crossmap xmap() Source: https://progressify.futureverse.org/articles/progressify-23-crossmap.html Use progressify() by piping the output of xmap() to it. Ensure progressify and handlers are loaded. This example emulates work with Sys.sleep(0.1). ```r library(progressify) handlers(global = TRUE) library(crossmap) slow_fcn <- function(x, y) { Sys.sleep(0.1) # emulate work x * y } xs <- list(1:5, 1:5) ys <- xmap(xs, slow_fcn) |> progressify() ``` -------------------------------- ### Get Supported Packages Source: https://progressify.futureverse.org/index.html Use progressify_supported_packages() to programmatically retrieve a list of all packages that currently have map-reduce functions compatible with progressify(). ```R progressify_supported_packages() ``` -------------------------------- ### Progressify Base R lapply with BiocGenerics Attached Source: https://progressify.futureverse.org/articles/progressify-11-base.html When BiocGenerics is attached, its S4 generic functions override base R's. This example shows how to explicitly call the base R version of lapply using base::lapply to ensure progressify works correctly. ```R y <- base::lapply(1:3, sqrt) |> progressify() ``` -------------------------------- ### Run bootstrap with progress signaling Source: https://progressify.futureverse.org/articles/progressify-81-boot.html This snippet shows how to use progressify() with the boot() function to display progress during bootstrap replicate calculations. Ensure progressify and boot libraries are loaded, and handlers are set globally. ```R library(progressify) handlers(global = TRUE) library(boot) # Run bootstrap with progress signaling x <- 1:100 my_stat <- function(data, i) mean(data[i]) res <- boot(data = x, statistic = my_stat, R = 1000) |> progressify() ``` -------------------------------- ### Fit random-slope model and run bootstrap with progress signaling (detailed) Source: https://progressify.futureverse.org/articles/progressify-81-lme4.html This snippet shows the detailed steps to fit a random-slope model, define a statistic function, and then run a bootstrap with progress signaling using bootMer and progressify. It includes loading necessary libraries and setting global handlers. ```R library(lme4) library(progressify) handlers(global = TRUE) # Fit random-slope model fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy) my_stat <- function(fit) { fixef(fit) } res <- bootMer(fm1, my_stat, nsim = 1000) |> progressify() ``` -------------------------------- ### Add progress reporting to boot() Source: https://progressify.futureverse.org/articles/progressify-81-boot.html This snippet demonstrates how to integrate progressify() with the boot() function to visualize the progress of bootstrap calculations. It requires loading both the boot and progressify libraries and setting global handlers. ```R library(boot) library(progressify) handlers(global = TRUE) x <- 1:100 my_stat <- function(data, i) mean(data[i]) res <- boot(data = x, statistic = my_stat, R = 1000) |> progressify() ``` -------------------------------- ### Add support for boot::boot() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with the boot::boot() function for progress updates. Requires the boot package. ```R res <- boot::boot(data, statistic, R = 100) |> progressify() ``` -------------------------------- ### Basic Usage of progressify() Source: https://progressify.futureverse.org/index.html Demonstrates how to apply progressify() to standard R, purrr, crossmap, foreach, and plyr map-reduce functions. Ensure progressr handlers are set globally for immediate effect. ```R library(progressify) handlers(global = TRUE) xs <- 1:10 ys <- lapply(xs, function(x) { Sys.sleep(0.1); sqrt(x) }) |> progressify() ``` ```R d <- as.dendrogram(hclust(dist(USArrests))) d2 <- dendrapply(d, function(n) { Sys.sleep(0.01); n }) |> progressify() ``` ```R xs <- 1:10 ys <- purrr::map(xs, function(x) { Sys.sleep(0.1); sqrt(x) }) |> progressify() ``` ```R xs <- list(1:5, 1:5) ys <- crossmap::xmap(xs, ~ .y * .x) |> progressify() ``` ```R library(foreach) xs <- 1:10 ys <- foreach(x = xs) %do% { Sys.sleep(0.1); sqrt(x) } |> progressify() ``` ```R xs <- 1:10 ys <- plyr::llply(xs, function(x) { Sys.sleep(0.1); sqrt(x) }) |> progressify() ``` -------------------------------- ### Add support for SimDesign::runSimulation() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with the SimDesign::runSimulation() function for progress updates. Requires the SimDesign package. ```R res <- SimDesign::runSimulation(design, replications, generate, analyse, summarise) |> progressify() ``` -------------------------------- ### Progressify with futurize for Parallel Processing Source: https://progressify.futureverse.org/articles/progressify-11-base.html Shows how to combine progressify with futurize to achieve both parallelization and progress reporting in a single pipeline. Requires futurize and progressify to be loaded, and a future plan to be set. ```R library(futurize) plan(multisession) library(progressify) handlers(global = TRUE) xs <- 1:100 ys <- lapply(xs, slow_fcn) |> futurize() |> progressify() ``` -------------------------------- ### Run SimDesign Simulation with Progressify and Handlers Source: https://progressify.futureverse.org/articles/progressify-81-SimDesign.html This snippet demonstrates running a SimDesign simulation and piping it to progressify() after loading necessary libraries and setting global handlers. This enables progressr-based reporting. ```r library(SimDesign) library(progressify) handlers(global = TRUE) res <- runSimulation(design = Design, replications = 100, generate = Generate, analyse = Analyse, summarise = Summarise) |> progressify() ``` -------------------------------- ### dendrapply with Progressify and Global Handlers Source: https://progressify.futureverse.org/articles/progressify-11-stats.html Demonstrates adding progress reporting to dendrapply using progressify and setting global handlers. This is the recommended approach for integrating progress updates. ```R library(progressify) handlers(global = TRUE) d2 <- dendrapply(d, function(n) { Sys.sleep(0.01); n }) |> progressify() ``` -------------------------------- ### Run fractional weighted bootstrap with progressify and explicit verbose=FALSE Source: https://progressify.futureverse.org/articles/progressify-81-fwb.html This snippet demonstrates using progressify() with the fwb function, explicitly setting verbose=FALSE to avoid dual reporting. Ensure progressify and fwb libraries are loaded, and global handlers are set. ```R library(fwb) library(progressify) handlers(global = TRUE) my_stat <- function(data, w) coef(lm(mpg ~ cyl, data = data, weights = w)) res <- fwb(data = mtcars, statistic = my_stat, R = 1000) |> progressify() ``` -------------------------------- ### Run SimDesign Simulation with Progressify Source: https://progressify.futureverse.org/articles/progressify-81-SimDesign.html This snippet shows how to run a SimDesign simulation and pipe the result to progressify() for progress reporting. Ensure progressify and SimDesign are loaded, and handlers are set globally. ```r library(progressify) handlers(global = TRUE) library(SimDesign) # Create small design Design <- createDesign(factor1 = c(1, 2)) Generate <- function(condition, fixed_objects = NULL) { rnorm(100) } Analyse <- function(condition, dat, fixed_objects = NULL) { mean(dat) } Summarise <- function(condition, results, fixed_objects = NULL) { mean(results) } # Run simulation with progress signaling res <- runSimulation(design = Design, replications = 100, generate = Generate, analyse = Analyse, summarise = Summarise) |> progressify() ``` -------------------------------- ### Add progress to foreach loop with progressify Source: https://progressify.futureverse.org/articles/progressify-41-foreach.html Demonstrates adding progress reporting to a foreach loop using progressify(). Requires loading progressify and foreach libraries and setting global handlers. ```R library(foreach) library(progressify) handlers(global = TRUE) xs <- 1:100 ys <- foreach(x = xs) %do% slow_fcn(x) |> progressify() ``` -------------------------------- ### Add support for foreach %dofuture% with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with foreach loops using the %dofuture% operator for progress updates. Requires the doFuture package. ```R y <- foreach(x = xs) %dofuture% { fcn(x) } |> progressify() ``` -------------------------------- ### Basic furrr::future_map usage Source: https://progressify.futureverse.org/articles/progressify-22-furrr.html Demonstrates the basic usage of furrr's future_map for parallel processing without progress reporting. Requires furrr and a parallel plan. ```R library(furrr) plan(multisession) xs <- 1:100 ys <- xs |> future_map(slow_fcn) ``` -------------------------------- ### Run fractional weighted bootstrap with progress signaling Source: https://progressify.futureverse.org/articles/progressify-81-fwb.html Use this snippet to run the fwb function with progress signaling enabled via progressify(). Ensure progressify and fwb libraries are loaded, and global handlers are set. ```R library(progressify) handlers(global = TRUE) library(fwb) # Run fractional weighted bootstrap with progress signaling my_stat <- function(data, w) coef(lm(mpg ~ cyl, data = data, weights = w)) res <- fwb(data = mtcars, statistic = my_stat, R = 1000) |> progressify() ``` -------------------------------- ### Add support for foreach %do% with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with foreach loops using the %do% operator for progress updates. Requires the foreach package. ```R y <- foreach(x = xs) %do% { fcn(x) } |> progressify() ``` -------------------------------- ### Basic Progressify Usage with lapply Source: https://progressify.futureverse.org/articles/progressify-11-base.html Demonstrates how to add progress reporting to the base R lapply function. Ensure progressify and handlers are loaded. ```R library(progressify) handlers(global = TRUE) slow_fcn <- function(x) { Sys.sleep(0.1) # emulate work x^2 } xs <- 1:100 ys <- lapply(xs, slow_fcn) |> progressify() ``` -------------------------------- ### Fit random-slope model and run bootstrap with progress signaling Source: https://progressify.futureverse.org/articles/progressify-81-lme4.html This snippet shows how to fit a random-slope model using lmer, define a statistic function, and then run a bootstrap with progress signaling using bootMer and progressify. Ensure progressify and lme4 are loaded, and handlers are set globally. ```R library(progressify) handlers(global = TRUE) library(lme4) # Fit random-slope model fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy) my_stat <- function(fit) { fixef(fit) } # Run bootstrap with progress signaling res <- bootMer(fm1, my_stat, nsim = 1000) |> progressify() ``` -------------------------------- ### Progressify vcovBS() with progress reporting Source: https://progressify.futureverse.org/articles/progressify-81-sandwich.html Shows how to add progress reporting to the vcovBS() function using the progressify() pipe. Ensure progressify is loaded and handlers are set globally. ```R library(sandwich) library(progressify) handlers(global = TRUE) fit <- lm(dist ~ speed, data = cars) v <- vcovBS(fit, R = 100L) |> progressify() ``` -------------------------------- ### List all supported packages Source: https://progressify.futureverse.org/reference/progressify_supported_packages.html Retrieve a character vector of all package names that are known to support progressify. This is useful for understanding the ecosystem compatibility. ```R pkgs <- progressify_supported_packages() print(pkgs) ``` -------------------------------- ### Add progress reporting to crossmap xmap() with progressify Source: https://progressify.futureverse.org/articles/progressify-23-crossmap.html Shows how to integrate progressify() with crossmap's xmap() function for visual progress updates. Requires loading both libraries and setting up handlers. ```r library(crossmap) library(progressify) handlers(global = TRUE) xs <- list(1:5, 1:5) ys <- xmap(xs, slow_fcn) |> progressify() ``` -------------------------------- ### Add support for lme4::bootMer() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with the lme4::bootMer() function for progress updates. Requires the lme4 package. ```R res <- lme4::bootMer(fit, statistic, nsim = 100) |> progressify() ``` -------------------------------- ### Basic vcovBS() usage without progress reporting Source: https://progressify.futureverse.org/articles/progressify-81-sandwich.html Demonstrates the standard usage of the vcovBS() function from the sandwich package without any progress reporting. This serves as a baseline for comparison. ```R library(sandwich) fit <- lm(dist ~ speed, data = cars) v <- vcovBS(fit, R = 100L) ``` -------------------------------- ### Basic crossmap xmap() usage Source: https://progressify.futureverse.org/articles/progressify-23-crossmap.html Demonstrates the basic usage of xmap() from the crossmap package to compute the cross product of list elements. This function does not provide progress feedback by default. ```r library(crossmap) xs <- list(1:5, 1:5) ys <- xmap(xs, slow_fcn) ``` -------------------------------- ### Progressify vcovBS() with 100 bootstrap replications Source: https://progressify.futureverse.org/articles/progressify-81-sandwich.html Adds progress reporting to the vcovBS() function from the sandwich package. Requires loading progressify and setting global handlers. Use this when performing a large number of bootstrap replications for covariance estimation. ```R library(progressify) handlers(global = TRUE) library(sandwich) fit <- lm(dist ~ speed, data = cars) v <- vcovBS(fit, R = 100L) |> progressify() ``` -------------------------------- ### Add progress to doFuture foreach loop Source: https://progressify.futureverse.org/articles/progressify-41-foreach.html Enables progress reporting for parallel foreach evaluations using doFuture's %dofuture% operator by piping to progressify(). Requires loading doFuture, progressify, and setting up the parallel plan. ```R library(doFuture) plan(multisession) library(progressify) handlers(global = TRUE) xs <- 1:100 ys <- foreach(x = xs) %dofuture% slow_fcn(x) |> progressify() ``` -------------------------------- ### progressify_supported_packages() and progressify_supported_functions() Source: https://progressify.futureverse.org/reference/index.html Lists all packages and specific functions that are compatible with progressification using the progressify package. This helps users identify which of their existing workflows can be enhanced with progress updates. ```APIDOC ## progressify_supported_packages() and progressify_supported_functions() ### Description List packages and functions supporting progressification. ### Method Not applicable (function calls) ### Parameters These functions do not require any parameters. ### Request Example ```r # Get a list of supported packages supported_pkgs <- progressify_supported_packages() # Get a list of supported functions supported_funcs <- progressify_supported_functions() ``` ### Response Returns a list or vector containing the names of supported packages or functions. #### Success Response A character vector of package names or function names. #### Response Example ```r # Example output for progressify_supported_packages(): # c("boot", "fwb", "lme4", ...) # Example output for progressify_supported_functions(): # c("lme4::lmer", "stats::kmeans", ...) ``` ``` -------------------------------- ### Basic future_lapply usage Source: https://progressify.futureverse.org/articles/progressify-12-future.apply.html Demonstrates the basic usage of future_lapply for parallel processing without progress reporting. Requires future.apply to be loaded and a future plan to be set. ```r library(future.apply) plan(multisession) xs <- 1:100 ys <- future_lapply(xs, slow_fcn) ``` -------------------------------- ### Run fractional weighted bootstrap without progressify Source: https://progressify.futureverse.org/articles/progressify-81-fwb.html This snippet shows the basic usage of the fwb function to generate fractional weighted bootstrap replicates without progressify. By default, it uses verbose=TRUE for progress feedback via pbapply. ```R library(fwb) my_stat <- function(data, w) coef(lm(mpg ~ cyl, data = data, weights = w)) res <- fwb(data = mtcars, statistic = my_stat, R = 1000) ``` -------------------------------- ### Apache License Boilerplate Source: https://progressify.futureverse.org/LICENSE.html This is the standard boilerplate notice to include when applying the Apache License to your work. Replace bracketed information with your project's details. ```text Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ``` -------------------------------- ### Add Progress Reporting to cforest() with Progressify Source: https://progressify.futureverse.org/articles/progressify-81-partykit.html This snippet shows how to add progress reporting to the 'cforest()' function from the 'partykit' package by piping its output to 'progressify()'. Ensure 'progressify' and 'partykit' are loaded, and handlers are set globally. ```R library(progressify) handlers(global = TRUE) library(partykit) data("Titanic", package = "datasets") tt <- as.data.frame(Titanic) forest <- cforest(Survived ~ ., data = tt, ntree = 50L) |> progressify() ``` -------------------------------- ### Add support for fwb::fwb() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with the fwb::fwb() function for progress updates. Requires the fwb package. ```R res <- fwb::fwb(data, statistic, R = 100) |> progressify() ``` -------------------------------- ### List supported functions for a specific package Source: https://progressify.futureverse.org/reference/progressify_supported_packages.html Retrieve a character vector of function names from a specified package that support progressify. This helps in identifying specific functions to instrument with progress updates. ```R fcns <- progressify_supported_functions("base") print(fcns) ``` -------------------------------- ### Transpile R Expression Source: https://progressify.futureverse.org/reference/transpile.html Demonstrates the basic usage of the transpile function to transform and evaluate an R expression. The 'when' argument controls whether transpilation occurs. ```r transpile( expr, options = list(...), ..., when = TRUE, eval = TRUE, envir = parent.frame(), disable = FALSE, type = "built-in", what = "transpile", unwrap = list(base::`{`, base::`(`, base::`!`, base::local, base::with, base::I, base::identity, base::invisible, base::suppressMessages, base::suppressWarnings, base::suppressPackageStartupMessages), debug = FALSE ) ``` -------------------------------- ### Add support for replicate() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with the base R replicate() function for progress updates. ```R y <- replicate(n, rnorm(10)) |> progressify() ``` -------------------------------- ### Add support for future.apply::future_lapply() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with future.apply::future_lapply() for progress updates. Requires the future.apply package. ```R y <- future.apply::future_lapply(xs, fcn) |> progressify() ``` -------------------------------- ### Add support for sandwich::vcovBS() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with the sandwich::vcovBS() function for progress updates. Requires the sandwich package. ```R v <- sandwich::vcovBS(fit) |> progressify() ``` -------------------------------- ### Purrr Map with Progressify using Pipe Syntax Source: https://progressify.futureverse.org/articles/progressify-21-purrr.html Shows how to integrate progressify with purrr's map function when using the pipe operator. This is an alternative to the base R function call syntax and requires loading progressify and setting global handlers. ```R library(purrr) library(progressify) handlers(global = TRUE) xs <- 1:100 ys <- xs |> map(slow_fcn) |> progressify() ``` -------------------------------- ### Add support for crossmap::xmap() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with crossmap::xmap() for progress updates. Requires the crossmap package. ```R y <- crossmap::xmap(xs, fcn) |> progressify() ``` -------------------------------- ### Progressify vcovJK() with progress reporting Source: https://progressify.futureverse.org/articles/progressify-81-sandwich.html Adds progress reporting to the vcovJK() function from the sandwich package. This is useful for visualizing the progress of jackknife covariance estimation. ```R library(sandwich) library(progressify) handlers(global = TRUE) fit <- lm(dist ~ speed, data = cars) v <- vcovJK(fit) |> progressify() ``` -------------------------------- ### Basic PLYR llply() Usage Source: https://progressify.futureverse.org/articles/progressify-51-plyr.html Demonstrates the standard usage of the llply() function from the PLYR package without any progress reporting. This serves as a baseline for comparison. ```R library(plyr) xs <- 1:100 ys <- llply(xs, slow_fcn) ``` -------------------------------- ### Adding Progressify to PLYR llply() Source: https://progressify.futureverse.org/articles/progressify-51-plyr.html Shows how to integrate progressify() with the PLYR llply() function by piping the output. This enables visual progress updates during execution. Ensure progressify and handlers are loaded. ```R library(plyr) library(progressify) handlers(global = TRUE) xs <- 1:100 ys <- llply(xs, slow_fcn) |> progressify() ``` -------------------------------- ### Add support for purrr::map() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with purrr::map() for progress updates. Requires the purrr package. ```R y <- purrr::map(xs, fcn) |> progressify() ``` -------------------------------- ### Add support for furrr::future_map() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with furrr::future_map() for progress updates. Requires the furrr package. ```R y <- furrr::future_map(xs, fcn) |> progressify() ``` -------------------------------- ### Add support for crossmap::future_xmap() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with crossmap::future_xmap() variants for progress updates. Requires the crossmap package. ```R y <- crossmap::future_xmap(xs, fcn) |> progressify() ``` -------------------------------- ### transpile Source: https://progressify.futureverse.org/reference/transpile.html Transpiles and optionally evaluates an R expression with configurable options. ```APIDOC ## Function: transpile ### Description Transpiles an R expression, with options to control evaluation, environment, and transpilation type. It can also unwrap specific functions to transpile expressions within them. ### Usage ```R transpile( expr, options = list(...), ..., when = TRUE, eval = TRUE, envir = parent.frame(), disable = FALSE, type = "built-in", what = "transpile", unwrap = list(base::`{`, base::`(`, base::`!`, base::local, base::with, base::I, base::identity, base::invisible, base::suppressMessages, base::suppressWarnings, base::suppressPackageStartupMessages), debug = FALSE ) ``` ### Arguments * **expr**: An R expression to transpile. Special values: FALSE disables transpilation, TRUE re-enables it, NA returns the transpiler's enabled status. * **options**: (optional) Named options for the transpilation. * **...**: Additional arguments for options. * **when**: If TRUE (default), the expression is transpiled; otherwise, it is not. * **eval**: If TRUE (default), the transpiled expression is evaluated; otherwise, it is returned. * **envir**: The environment where the expression should be evaluated. * **disable**: If TRUE, the transpiler is disabled. * **type**: Type of the transpiler to use (default: "built-in"). * **what**: Operation to perform (default: "transpile"). * **unwrap**: (optional) A list of functions to unwrap for transpilation (e.g., `{ ... }`, `local( ... )`). * **debug**: If TRUE, enables debug mode. ### Value Returns the evaluated result of `expr` if `eval = TRUE`, otherwise the transpiled expression. If `expr` is NA, returns TRUE if the transpiler is enabled, otherwise FALSE. ``` -------------------------------- ### Standard Purrr Map without Progress Source: https://progressify.futureverse.org/articles/progressify-21-purrr.html Illustrates the standard usage of purrr's map function without any progress reporting. This serves as a baseline to show the effect of adding progressify. ```R library(purrr) xs <- 1:100 ys <- map(xs, slow_fcn) ``` -------------------------------- ### Add support for purrr::map() with progressify (0.0.1) Source: https://progressify.futureverse.org/news/index.html Use progressify with purrr::map() for progress updates. Requires the purrr package. This is an earlier version of the support. ```R y <- map(xs, fcn) |> progressify() ``` -------------------------------- ### Basic foreach loop without progress Source: https://progressify.futureverse.org/articles/progressify-41-foreach.html A standard foreach loop without progress reporting. This serves as a baseline for comparison. ```R library(foreach) xs <- 1:100 ys <- foreach(x = xs) %do% slow_fcn(x) ``` -------------------------------- ### Add progress to foreach loop Source: https://progressify.futureverse.org/articles/progressify-41-foreach.html Pipe the result of a foreach loop to progressify() to enable progress reporting. Ensure progressify and foreach libraries are loaded, and handlers are set globally. ```R library(progressify) handlers(global = TRUE) library(foreach) slow_fcn <- function(x) { Sys.sleep(0.1) # emulate work x^2 } xs <- 1:100 ys <- foreach(x = xs) %do% slow_fcn(x) |> progressify() ``` -------------------------------- ### Progressify lapply with Handlers Source: https://progressify.futureverse.org/reference/progressify.html This snippet demonstrates how to use progressify with the base R lapply function to add progress updates. Ensure handlers are set up to listen to these updates. ```R handlers(global = TRUE) # listen to progress updates #> Error in globalCallingHandlers(condition = global_progression_handler): should not be called with handlers on the stack xs <- list(1, 1:2, 1:2, 1:5) y <- lapply(X = xs, FUN = sum) |> progressify() str(y) #> List of 4 #> $ : num 1 #> $ : int 3 #> $ : int 3 #> $ : int 15 ``` -------------------------------- ### Basic dendrapply Usage Source: https://progressify.futureverse.org/articles/progressify-11-stats.html This is the standard usage of the dendrapply function from the stats package without progress reporting. ```R d <- as.dendrogram(hclust(dist(USArrests))) d2 <- dendrapply(d, function(n) { Sys.sleep(0.01); n }) ``` -------------------------------- ### Add support for stats::dendrapply() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with the base R stats::dendrapply() function for progress updates. Requires the stats package. ```R d2 <- dendrapply(d, fcn) |> progressify() ``` -------------------------------- ### Fit random-slope model using lmer Source: https://progressify.futureverse.org/articles/progressify-81-lme4.html This code snippet demonstrates fitting a random-slope model using the lmer function from the lme4 package. It sets up the model formula and data, but does not include progress reporting. ```R library(lme4) # Fit random-slope model fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy) my_stat <- function(fit) { fixef(fit) } res <- bootMer(fm1, my_stat, nsim = 1000) ``` -------------------------------- ### Add progress reporting to future_lapply Source: https://progressify.futureverse.org/articles/progressify-12-future.apply.html Use progressify() to add progress reporting to future_lapply. Ensure progressify and future.apply are loaded, and a future plan is set. The progress reporting will appear using the default handler. ```r library(progressify) handlers(global = TRUE) library(future.apply) plan(multisession) slow_fcn <- function(x) { Sys.sleep(0.1) # emulate work x^2 } xs <- 1:100 ys <- future_lapply(xs, slow_fcn) |> progressify() ``` -------------------------------- ### Add support for purrr::imap_vec() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with purrr::imap_vec() for progress updates. Requires the purrr package. ```R purrr::imap_vec(xs, fcn) |> progressify() ``` -------------------------------- ### Add progress to furrr::future_map Source: https://progressify.futureverse.org/articles/progressify-22-furrr.html Use progressify() to add progress reporting to furrr's future_map. Ensure progressify and furrr are loaded, and a parallel plan is set. ```R library(progressify) handlers(global = TRUE) library(furrr) plan(multisession) slow_fcn <- function(x) { Sys.sleep(0.1) # emulate work x^2 } xs <- 1:100 ys <- xs |> future_map(slow_fcn) |> progressify() ``` -------------------------------- ### Add Progress to dendrapply with Progressify Source: https://progressify.futureverse.org/articles/progressify-11-stats.html Use this snippet to add progress reporting to the dendrapply function from the stats package. Ensure progressify and stats are loaded, and handlers are set globally. ```R library(progressify) handlers(global = TRUE) library(stats) d <- as.dendrogram(hclust(dist(USArrests))) d2 <- dendrapply(d, function(n) { Sys.sleep(0.01); n }) |> progressify() ``` -------------------------------- ### Add support for furrr *_vec() variants with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with furrr's future_*_vec() functions like future_map_vec(), future_map2_vec(), future_pmap_vec(), and future_imap_vec(). Requires the furrr package. ```R future_map_vec(xs, fcn) |> progressify() ``` ```R future_map2_vec(xs, ys, fcn) |> progressify() ``` ```R future_pmap_vec(list(xs, ys), fcn) |> progressify() ``` ```R future_imap_vec(xs, fcn) |> progressify() ``` -------------------------------- ### Add support for plyr::llply() with progressify Source: https://progressify.futureverse.org/news/index.html Use progressify with plyr::llply() for progress updates. Requires the plyr package. ```R y <- plyr::llply(xs, fcn) |> progressify() ``` -------------------------------- ### progressify Source: https://progressify.futureverse.org/reference/progressify.html Evaluates a regular map-reduce call with progress updates. This function wraps an R expression, enabling progress tracking during its execution. ```APIDOC ## progressify ### Description Evaluates a regular map-reduce call with progress updates. This function wraps an R expression, enabling progress tracking during its execution. ### Usage ```R progressify( expr, substitute = TRUE, ..., when = TRUE, eval = TRUE, envir = parent.frame() ) ``` ### Arguments * **expr** (An R expression.) - The R expression to be evaluated with progress updates. * **substitute** (logical) - If TRUE (default), `expr` is quoted. * **...** - Not used. * **when** (logical) - If TRUE (default), the expression is progressified; otherwise, it is not. * **eval** (logical) - If TRUE (default), the progressified expression is evaluated; otherwise, it is returned. * **envir** (environment) - The environment in which `expr` is evaluated. ### Value Returns the value of the evaluated expression `expr`. ### Examples ```R handlers(global = TRUE) # listen to progress updates xs <- list(1, 1:2, 1:2, 1:5) y <- lapply(X = xs, FUN = sum) |> progressify() str(y) ``` ``` -------------------------------- ### progressify() Source: https://progressify.futureverse.org/reference/index.html Evaluates a regular map-reduce call and provides progress updates. This function is the primary interface for integrating progress tracking into iterative or parallel computations. ```APIDOC ## progressify() ### Description Evaluate a regular map-reduce call with progress updates. ### Method Not applicable (function call) ### Parameters This function takes arguments relevant to the map-reduce call it is wrapping. Specific parameters depend on the underlying map-reduce framework being used. ### Request Example ```r # Example usage (conceptual): # result <- progressify(some_map_reduce_function, data, other_args) ``` ### Response Returns the result of the map-reduce operation with progress updates. #### Success Response The computed result of the map-reduce operation. #### Response Example ```r # Conceptual example of a returned result # list(result1, result2, ...) ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.