Description Usage Arguments Details Value Warning Author(s) See Also Examples
Extrapolates the binning of categorical variables to the new datasets.
1 | apply.tbin(idv, train.output, test)
|
idv |
Predictor variables in the dataframe which are categorical and need to be binned. |
train.output |
The output object of the tbin function. |
test |
A new data set on which binning has to be extrapolated. |
This function performs binning on the new dataset based on the output object from the tbin function.
Returns a dataframe which contains the extrapolated variables of the output object from tbin function appended to the new dataset.
New level error is thrown if the new dataset contains new levels other than what is present in the old dataset.
Mohan Manivannan
tbin
, ctoc
, apply.ctoc
.
1 2 3 4 5 6 7 8 9 10 | train = as.data.frame(cbind(runif(1000, 10, 1000),sample(1:40, 1000,TRUE)))
colnames(train) = c("response","state")
train$state = as.factor(train$state)
train.output = tbin(dv = "response",idv = c("state"),train,25,TRUE)
# extrapolating the tbin function to a new dataset using apply.tbin
test = as.data.frame(sample(1:40, 100,TRUE))
colnames(test) = c("state")
test$state = as.factor(test$state)
test.output = apply.tbin(idv = c("state"), train.output, test)
|
Loading required package: ggplot2
Loading required package: gplots
Attaching package: 'gplots'
The following object is masked from 'package:stats':
lowess
Loading required package: RColorBrewer
Loading required package: igraph
Attaching package: 'igraph'
The following objects are masked from 'package:stats':
decompose, spectrum
The following object is masked from 'package:base':
union
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.