Description Usage Arguments See Also Examples
The functions purpose is to recategorize a data.frame's variables by the elements identified in a list. Each element of the list must contain two columns. The first column contains the original values, and the second column contains the new values. The first column name of each element of the list must be a variable name in the data.frame. Effectively, each element of the list is a mapping table. The list generated from the tree.bins() function can be directly passed as an element to this function.
1 |
list |
A list generated from the tree.bins() function or created by the user to the specifications laid out in the description. |
data |
A data.frame. |
tree.bins
, fct_relevel
, factor
, left_join
1 2 3 4 5 6 7 | #Allows the user to generate a list from the tree.bins() function
sample.df <- AmesImpFctrs[, c("Neighborhood", "MS.Zoning", "SalePrice")]
lookup.list <- tree.bins(data = sample.df, y = SalePrice, return = "lkup.list")
#Create a new data.frame and use the created list to map recategorize its values
new.df <- head(AmesImpFctrs[, c("Neighborhood", "MS.Zoning", "Lot.Shape", "SalePrice")], 100)
oth.binned.df <- bin.oth(list = lookup.list, data = new.df)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.