divide {StabPerf} | R Documentation |
Divides various data types into *blocks* for use in parallel processing
Description
Divides matrices, data.frames, lists, and vectors into lists of subsets of the orginal data.
Usage
divide(data, divisions=NULL, by.row=FALSE, by.col=FALSE)
Arguments
data |
matrix, vector, list, or data.frame. Must be numeric . |
divisions |
integer. How many times to break up the data |
by.row |
logical. Whether matrices and data.frames should be split along rows |
by.col |
logical. Whether matrices and data.frames should be split along columns |
Details
If divisions
is not specified, it is based on the number of currently active nodes in the running cluster, if one is running. Divisions cannot be less than 2
. If the size of the input data
cannot be evenly divided by divisions
the data will be distributed as evenly as possible. The order of the original data is not changed. You cannot use by.row
and by.col
together in the same call.
Value
list |
list of things of the same type as data |
Examples
# Returns a list of two vectors, equally long
divide(1:10, 2)
# Returns a list of matrices, one matrix will have 2 columns, the other 3
divide(matrix(1:10,nrow=2), 5, by.col=TRUE)
# Note: this returns what it was passed, without changing anything
divide(list(1:32), 3)
# This, however, is a list of sub-lists and the sub-lists will be rearranged
# such that two lists are returned. Each of these is a list of lists of the
# original data.
divide(list(list(0:10),list(20:30), list(40:50)), 2)
[Package
StabPerf version 0.5
Index]