parseJob: Parses a collection of elements into (almost) equal sized...

Description Usage Arguments Value Author(s) Examples

Description

Parses a collection of elements into (almost) equal sized groups. Useful for splitting up an R job that operates over a large dataframe or list into multiple jobs.

Usage

1
2
parseJob(n, njobs, collate = FALSE, random.seed = NULL,
  text.to.eval = FALSE)

Arguments

n

The number elements to be parsed

njobs

The number of groups

collate

=TRUE alternative ordering of the grouping. See example below.

random.seed

An integer setting the random seed, which will result in randomizing the elements among the jobs. If NULL, no randomization is performed. Randomization cannot be performed if collate = TRUE or if text.to.eval = TRUE. Randomization is useful when the computing time for each element varies significantly because it helps to even out the run times of parallel jobs.

text.to.eval

If = TRUE, a text expression is returned, that when evaluated, will produce the sequence of elements for that group. This is especially useful when n is very large. (See Value section below).

Value

When text.to.eval = FALSE, a list with njobs elements is returned, each element containing a numeric vector of the element numbers which correspond to that group. When text.to.eval = TRUE, a list with njobs elements is returned, each element containing text (let's call it val), that when evaluated using eval(parse(text = val)), will produce the sequence of numbers corresponding to the group.

Author(s)

Landon Sego

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
x <- parseJob(29, 6)
print(x)

# To see the range of each group
lapply(x, range)

# To see the length of each group
lapply(x, length)

# Randomize the outcome
parseJob(32, 5, random.seed = 231)

# Example of text.to.eval
parseJob(11, 3, text.to.eval = TRUE)
lapply(parseJob(11, 3, text.to.eval = TRUE), function(x) eval(parse(text = x)))

# Example of collated and text.to.eval
parseJob(11, 3, collate = TRUE)
parseJob(11, 3, collate = TRUE, text.to.eval = TRUE)

PNNL-Comp-Mass-Spec/glmnetGLR documentation built on May 28, 2019, 2:23 p.m.