bin_vector: Snap continuous values to a grid

View source: R/bin_vector.R

bin_vectorR Documentation

Snap continuous values to a grid


This function bins a continuously valued vector based on user-defined bins. It is useful for binning continuously valued genotypes. Each value in the matrix gets shifted to the nearest provided in the argument bins.


bin_vector(vectorX, bins = seq(0, 1, 0.5))



A vector of numeric values to bin


A vector of values to snap the values in vectorX to.


A vector the same length as vectorX in which each value in vectorX has been sent to the nearest value in bins. For example, if bins is c(0, 0.5, 1), and vectorX contains a 0.49. That 0.49 value will be sent to 0.5. The returned vector contains only the values specified in bins.

cape documentation built on May 20, 2022, 1:06 a.m.