binvec {matter} | R Documentation |
Bin a vector based on intervals or groups.
binvec(x, u, v, method = "sum")
x |
A numeric vector. |
u, v |
The (inclusive) lower and upper indices of the bins, or a factor providing the groupings. |
method |
The method used to bin the values. This is efficiently implemented for "sum", "mean", "min" or "max". Providing a function will use a less-efficient fallback. |
An vector of the summarized (binned) values.
Kylie A. Bemis
set.seed(1) x <- runif(20) binvec(x, c(1,6,11,16), c(5,10,15,20), method="mean") binvec(x, seq(from=1, to=21, by=5), method="mean") g <- rep(c("a","b","c","d"), each=5) binvec(x, g, method="mean")