Description Usage Arguments Details Value Author(s) See Also Examples
Extrapolating the categorical to continuous conversion that is calculated from one dataframe to another dataframe.
1 | apply.ctoc(y, x, data, newdata, min.obs)
|
y |
Response variable (categorical or continuous). |
x |
Predictor variables in the dataframe which are categorical and need to be converted into continuous. |
data |
Name of the dataframe from which the values of the categories have to be calculated. |
newdata |
Name of the dataframe to which the values of the categories have to be applied. |
min.obs |
The minimum number of observations within a category in a categorical variable to get converted into a continuous feature. All the categories which have observations less than the min.obs will form a different category. |
This function is only for categorical variables. The min.obs refers to the minimum number of observations in the "data".
Returns a dataframe with converted features without replacing the original ones.
Santhosh Sasanapuri
ctoc
, tbin
, apply.tbin
.
1 2 3 4 5 6 7 | data(ChickWeight)
set.seed(2)
sample_ex <- sample(nrow(ChickWeight), size = 289, replace = FALSE, prob = NULL)
train <- ChickWeight[sample_ex,]
test <- ChickWeight[-sample_ex,colnames(ChickWeight) != "weight"]
# Returns the test dataframe with an added column "Diet_cont" by extrapolating it from train
head(apply.ctoc(y = "weight", "Diet", data = train, newdata = test, min.obs = 60))
|
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
Diet Time Chick Diet_cont
1 1 0 1 102.4865
2 1 2 1 102.4865
3 1 4 1 102.4865
4 1 16 1 102.4865
5 1 18 1 102.4865
6 1 4 2 102.4865
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.