parseJob {Smisc} | R Documentation |
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.
parseJob(n, njobs, collate = FALSE, random.seed = NULL, text.to.eval = FALSE)
n |
The number elements to be parsed |
njobs |
The number of groups |
collate |
|
random.seed |
An integer setting the random seed, which will result in randomizing the
elements among the jobs. If |
text.to.eval |
If |
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.
Landon Sego
x <- parseJob(29, 6) print(x) # To see the range of each group lapply(x, range) # To see the length of each group lengths(x) # Randomize the outcome parseJob(32, 5, random.seed = 231) # Example of 'text.to.eval = TRUE' out <- parseJob(11, 3, text.to.eval = TRUE) out lapply(out, function(x) eval(parse(text = x))) # Example of 'collate = TRUE' and 'text.to.eval = TRUE' parseJob(11, 3, collate = TRUE) parseJob(11, 3, collate = TRUE, text.to.eval = TRUE)