powered by
Function that graphs the distribution of individuals and shows their category according to a categorical variable.
categorical.predictive.power( data, predict.variable, variable.to.compare, ylab = "", xlab = "", main = paste("Variable Distribution", variable.to.compare, "according to", predict.variable), col = NA )
A ggplot object.
A data frame.
Character type. The name of the variable to predict. This name must be part of the columns of the data frame.
Character type. The name of the categorical variable to compare. This name must be part of the columns of the data frame.
A character string that describes the y-axis on the graph.
A character string that describes the x-axis on the graph.
Character type. The main title of the chart.
A vector that specifies the colors of the categories of the variable to predict.
ggplot
cars <- datasets::mtcars cars$cyl <- as.factor(cars$cyl) cars$vs <- as.factor(cars$vs) categorical.predictive.power(cars,"vs","cyl")
Run the code above in your browser using DataLab