bin.oth: Recategorization of Variables by Mapping Tables Within a List

Description Usage Arguments See Also Examples

View source: R/bin.oth.R

Description

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.

Usage

1

Arguments

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.

See Also

tree.bins, fct_relevel, factor, left_join

Examples

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)

tree.bins documentation built on May 2, 2019, 12:20 p.m.