ch.numberVectorToGrps: A function to bin quantities into categories.

ch.numberVectorToGrpsR Documentation

A function to bin quantities into categories.

Description

This function bins quantities into categories.

Usage

ch.numberVectorToGrps(data, quantCol, catNameCol, quantValueCuts)

Arguments

data

a dataframe.

quantCol

a string the specifies the column name in "data" that contains the variable with the quantity. This will be "p1Quant" or "p2Quant" if the items were processed with ch.moralsEquateItemStringsForNumberQuantDataset().

catNameCol

a string the specifies the new column name in "data" that will be created to hold the new category names.

quantValueCuts

a vector of numbers that specifies the cutoff values for each quantity. The first category is <= to the first cutoff value; each successive category (c1, c2, etc) is c1 < X <= c2; the final category is greater than the last number in the vector.

Value

the dataframe (data) with the new category variable added.

Examples

ch.numberVectorToGrps (itemAnalDat, "p1Quant", c(1,9,40))

ccpluncw/ccpl_R_chutils documentation built on Feb. 28, 2024, 1:17 a.m.