byX {PTXQC} | R Documentation |
Calls FUN on a subset of data in blocks of size 'subset_size' of unique indices.
Description
One subset consists of 'subset_size' unique groups and thus of all rows which in 'data' which have any of these groups. The last subset might have less groups, if the number of unique groups is not dividable by subset_size.
Usage
byX(data, indices, subset_size = 5, FUN, sort_indices = TRUE, ...)
Arguments
data |
Data.frame whose subsets to use on FUN |
indices |
Vector of group assignments, same length as nrow(data) |
subset_size |
Number of groups to use in one subset |
FUN |
Function applied to subsets of data |
sort_indices |
Sort groups (by their sorted character(!) names) before building subsets |
... |
More arguments to FUN |
Details
FUN is applied on each subset.
Value
list of function result (one entry for each subset)
Examples
byX(data.frame(d=1:10), 1:10, 2, sum)
[Package PTXQC version 1.1.1 Index]