Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

splitpb

Divide Tasks for Progress-bar Friendly Distribution in a Cluster


Description

Divides up 1:nx into approximately equal sizes (ncl) as a way to allocate tasks to nodes in a cluster repeatedly while updating a progress bar.

Usage

splitpb(nx, ncl, nout = NULL)

Arguments

nx

Number of tasks.

ncl

Number of cluster nodes.

nout

Integer, maximum number of partitions in the output (must be > 0).

Value

A list of length min(nout, ceiling(nx / ncl)), each element being an integer vector of length ncl * k or less, where k is a tuning parameter constrained by the other arguments (k = max(1L, ceiling(ceiling(nx / ncl) / nout)) and k = 1 if nout = NULL).

Author(s)

Peter Solymos <solymos@ualberta.ca>

See Also

Parallel usage of pbapply and related functions.

Examples

## define 1 job / worker at a time and repeat
splitpb(10, 4)
## compare this to the no-progress-bar split
## that defines all the jubs / worker up front
parallel::splitIndices(10, 4)

## cap the length of the output
splitpb(20, 2, nout = NULL)
splitpb(20, 2, nout = 5)

pbapply

Adding Progress Bar to '*apply' Functions

v1.4-3
GPL-2
Authors
Peter Solymos [aut, cre], Zygmunt Zawadzki [aut]
Initial release
2020-08-11

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.