Categorical variables into Continuous features
Converting categorical variables into continuous features using the mean of the response variable for the respective categories without using the index record.
Response variable (categorical or continuous).
Predictor variables in the dataframe which are categorical and need to be converted into continuous.
Name of the dataframe.
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.
Returns a dataframe with converted features without replacing the original ones.
1 2 3 4 5
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))
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.