Description Usage Arguments Details Value See Also Examples
Generalize a Column
1 2 |
x |
a data.frame |
col |
the column that is to be generalized - may be numeric (column indices) or character (column names) |
splits |
numeric - numeric vector containing the numbers which should serve as boundary points between each numeric category. Either this or numSplits is a required argument for numeric generalization. |
numSplits |
numeric - number of splits desired. Either this or numeric is a required argument for numeric generalization |
rightClosed |
numeric - should boundaries be closed right? False by default |
newCategories |
categorical - new categories to replace the old |
mapping |
categorical - a numeric vector containing a mapping of old categories to new categories. See details for more information. |
This function calls either generalize_numeric or generalize_categorical depending on which arguments are provided. splits or numSplits are required for generalize_numeric, so if either of these arguments are provided, generalize_numeric will be called. newCategories and mapping are required for generalize_categorical. If neither splits nor numSplits is provided, and both newCategories and mapping are provided, then generalize_categorical is called.
data.frame with with specified column generalized
Other generalize.functions: generalizeCategorical
;
generalizeNumeric
1 2 3 4 5 6 | age <- c(51, 42, 23, 44, 25)
maritalStatus <- c("Married", "Single", "Single", "Divorced", "Married")
data <- data.frame(age, maritalStatus)
generalize(data, 1, splits=c(30, 50))
generalize(data, 2, newCategories=c("Has Been Married","Has Not Been Married"), mapping=c(1,2,1,1))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.