fwalk | R Documentation |
Applies a function '.f' to each element of '.x', typically for its side effects (e.g., printing, writing files). This function is the side-effect-friendly equivalent of 'fmap()'. Supports parallel execution and progress bar display.
fwalk(.x, .f, ncores = NULL, pb = FALSE, ...)
.x |
A list or atomic vector of elements to iterate over. |
.f |
A function to apply to each element of '.x'. Should be called primarily for side effects. |
ncores |
Integer. Number of cores to use for parallel processing. Default is 'NULL' (sequential). |
pb |
Logical. Whether to show a progress bar. Default is 'FALSE'. |
... |
Additional arguments passed to '.f'. |
Invisibly returns '.x', like 'purrr::walk()'.
# Print each element
fwalk(1:3, print)
# Simulate writing files in parallel
fwalk(1:3, function(i) {
cat(paste("Processing item", i, "\n"))
Sys.sleep(0.5)
}, ncores = 2, pb = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.