Learn R Programming

DataExplorer (version 0.5.0)

plot_correlation: Create correlation heatmap for discrete features

Description

This function creates a correlation heatmap for all discrete categories.

Usage

plot_correlation(data, type = c("all", "discrete", "continuous"),
  maxcat = 20, title = NULL, ...)

Arguments

data

input data to be plotted, in either data.frame or data.table format.

type

column type to be included in correlation calculation. "all" for all columns, "discrete" for discrete features, "continuous" for continuous features.

maxcat

maximum categories allowed for each discrete feature. The default is 20.

title

plot title

other arguments to be passed to cor.

Details

For discrete features, the function first dummifies all categories, then calculates the correlation matrix (see cor) and plots it.

Examples

Run this code
# NOT RUN {
# load diamonds dataset from ggplot2
data("diamonds", package = "ggplot2")

# Plot correlation heatmap with all columns
plot_correlation(diamonds)
# Plot correlation heatmap with discrete features only
plot_correlation(diamonds, type = "d")
# Plot correlation heatmap with continuous features only
plot_correlation(diamonds, type = "c")
# }

Run the code above in your browser using DataLab