generalizeNumeric: Generalize a Numeric Column

Description Usage Arguments Details Value See Also Examples

View source: R/generalizeNumeric.R

Description

Generalize a Numeric Column

Usage

1
2
generalizeNumeric(x, col, splits = NULL, numSplits = NULL,
  rightClosed = FALSE)

Arguments

x

a data.frame

col

the column that is to be generalized - may be numeric (column indices) or character (column names)

splits

numeric vector containing the numbers which should serve as boundary points between each numeric rangeory. Either splits or numSplits is a required argument for numeric generalization. If splits is provided, then numSplits is ignored.

numSplits

number of splits desired. Either splits or numSplits is a required argument for numeric generalization. If splits is provided, then numSplits is ignored.

rightClosed

should boundaries be closed right? False by default

newranges

rangeorical - new ranges to replace the old

Details

The function generalizes a numeric column by converting it into a rangeorical column, in which each rangeory contains a range of numbers. The numbers in splits is used as the boundary points between these ranges. If the numSplits argument is used instead of splits, then numSplit ranges of equal range are created, spanning from the smallest number in the column to the largest. By default, these ranges are left-closed, meaning that a rangeory captures elements that fall on its left boundary but not on its right boundary. rightClosed provides a right-closed option.

Value

data.frame with with specified column generalized

See Also

Other generalize.functions: generalizeCategorical; generalize

Examples

1
2
3
4
5
6
7
8
age <- c(51, 42, 23)
weight <- c(127, 150, 188)
IQ <- c(119, 101, 95)
data <- data.frame(age, weight, IQ)

generalize(data, 1, splits=c(30, 50))
generalize(data, 2, splits=180, rightClosed=TRUE)
generalize(data, 2, numSplits=2)

shuklak13/anonymizeR documentation built on May 29, 2019, 9:27 p.m.