| bin | R Documentation |
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,
returnMids = TRUE,
.check = TRUE
)
x |
|
y |
|
size |
|
breaks |
|
FUN |
|
returnMids |
|
.check |
|
Depending on the value of returnMids:
returnMids = TRUE (the default): returns a list with elements x
(aggregated values of x) and mids (the bin mid points).
returnMids = FALSE: returns a numeric with just the binned values for
x.
Johannes Rainer, Sebastian Gibb
Other grouping/matching functions:
closest(),
gnps()
## 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)
## Get only the binned values without the bin mid points.
bin(ints, mz, size = 2, returnMids = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.