ctoc {corkscrew} | R Documentation |
Categorical variables into Continuous features
Description
Converting categorical variables into continuous features using the mean of the response variable for the respective categories without using the index record.
Usage
ctoc(y, x, data, min.obs)
Arguments
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. |
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. |
Details
This function is only for categorical variables.
Value
Returns a dataframe with converted features without replacing the original ones.
Author(s)
Santhosh Sasanapuri
See Also
Examples
data(ChickWeight)
# Converting the "Chick" variable into factor from ord.factor for demonstration purposes.
ChickWeight$Chick <- as.factor(as.numeric(ChickWeight$Chick))
# Returns a dataframe with two added columns for "Chick" and "Diet"
head(ctoc(y = "weight", x = c("Chick","Diet"), data = ChickWeight, min.obs = 12))
[Package corkscrew version 1.1 Index]