Description Usage Arguments Details Value See Also Examples
View source: R/generalizeNumeric.R
Generalize a Numeric Column
1 2 | generalizeNumeric(x, col, splits = NULL, numSplits = NULL,
rightClosed = FALSE)
|
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 |
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.
data.frame with with specified column generalized
Other generalize.functions: generalizeCategorical
;
generalize
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.