Binning
Aggregate values in x
for bins defined on y
: all values
in x
for values in y
falling into a bin (defined on y
) are
aggregated with the provided function FUN
.
bin( x, y, size = 1, breaks = seq(floor(min(y)), ceiling(max(y)), by = size), FUN = max )
x |
|
y |
|
size |
|
breaks |
|
FUN |
|
list
with elements x
(aggregated values of x
) and mids
(the
bin mid points).
Johannes Rainer, Sebastian Gibb
Other grouping/matching functions:
closest()
## Define example intensities and m/z values ints <- abs(rnorm(20, mean = 40)) mz <- seq(1:length(ints)) + rnorm(length(ints), sd = 0.001) ## Bin intensities by m/z bins with a bin size of 2 bin(ints, mz, size = 2) ## Repeat but summing up intensities instead of taking the max bin(ints, mz, size = 2, FUN = sum)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.