This function generates equally-sized bins from a named numeric vector or from a summary statistic of a matrix's rows. If a matrix is provided, the numeric vector will first be computed; it will be of the same length as there are rows in the matrix, and each value will represent a summary statistic of each of the rows, the default being row means.

bin(mat = NULL, x = NULL, breaks = 30, FUN = rowMeans)

Arguments

mat

a matrix over whose rows to calculate a summary statistic and subsequently generate bins from. Default: NULL

x

a named numeric vector to generate bins from. Default: NULL

breaks

the number of desired bins. Default: 30

FUN

function to be applied to each row of a matrix. Must return a single numeric value per row. Default: rowMeans

Value

a named numeric vector, with as names the names of <x> or the rownames of <mat> and as values the bin IDs computed. If names(x) or rownames(mat) are NULL, the vector names will instead be the values that were binned (e.g. the row means)