make.bin.cols: Create a Bin Numbers Column for each Percentiles Column

View source: R/make.bin.cols.R

make.bin.colsR Documentation

Create a Bin Numbers Column for each Percentiles Column

Description

Simplifies creation of data.frame or matrix (or vector) with columns that specify bins by bin number, based on values (percentiles for example) and specified cutpoints. Each bin is defined by cutpoints.

Usage

make.bin.cols(
  pctile.df,
  as.df = TRUE,
  cutpoints = c((0:9)/10, 0.95, 1),
  labels = 1:11,
  prefix = "bin."
)

Arguments

pctile.df

Data.frame (or matrix or vector), required. Typically percentiles as decimal fractions, 0 to 1, one per place.

as.df

Logical value, optional, TRUE by default. Defines whether results are data.frame or matrix.

cutpoints

Optional vector of cutpoints defining edges of bins. Default is every 0.10 from 0 through 1.00, as well as 0.95

labels

Vector of bin numbers (defining what is returned for values in those bins), optional (default is 1 through 11, and NA values are put in bin 0).

prefix

Optional character element, ".bin" by default, pasted as prefix to each column name of pctile.df, and used as names of returned columns.

Details

This is one way to prepare data to be mapped in a series of choropleths, for example (color-coded maps).

The default bins 0-11 are defined as follows:
bin 0: PCTILE=NA
...
bin 9: 0.80<=PCTILE<0.90
bin 10: 0.90<=PCTILE<0.95
bin 11: 0.95<=PCTILE<=1.00

Value

Returns a data.frame, matrix, or vector (depending on as.df) the same shape as pctile.df

See Also

make.bin.pctile.cols() and assign.pctiles()

Examples

	#  new.bin.cols <- make.bin.cols(places[ , names.e.pctile])
	# new.bin.cols <- make.bin.cols( new.pctile.cols )

ejanalysis/ejanalysis documentation built on April 2, 2024, 10:12 a.m.