sortbin: sortbin

View source: R/sortbin.R

sortbinR Documentation

sortbin

Description

Sorts and bins the rows of the data frame x according the sorting columns in sortCol. decreasing and na.last are recycled is necessary. If equibin is TRUE and nBins==NA then nBins is set to 100. If equibin is FALSE and nBins==NA then the bins are returned as they come from sorting; only identical values are in one bin. If nBins is positive then the bins are merged until nBins reached. Note that the numbers of observations per bin may vary.

Usage

sortbin(
  x,
  sortCol = 1,
  decreasing = FALSE,
  na.last = TRUE,
  nBins = NA,
  equibin = TRUE
)

Arguments

x

data frame

sortCol

numeric/character: names or indices of variable used for sorting (default: 1)

decreasing

logical: should the sort order be increasing or decreasing (default: FALSE)

na.last

logical: for controlling the treatment of NAs (default: TRUE)

nBins

integer: maximal number of bins (default: NA).

equibin

logical: should the number of observations equal per bin (default: TRUE)

Value

(non-sequential) bin numbers as integer

Examples

data("Boston", package="MASS")
tableplot(Boston, bin=sortbin(Boston))

sigbertklinke/smvgraph documentation built on Dec. 10, 2022, 9:13 a.m.