This function creates a pairwise correlation plot with annotated correlation coefficients and optional coloring by a specified variable. The plot can be interactive or static.

corrPairs(
  data,
  method = c("pearson", "kendall", "spearman"),
  interactive = TRUE,
  col_by = NULL
)

Arguments

data

A data frame containing the variables to be plotted.

method

A character string specifying the correlation method. One of "pearson", "kendall", or "spearman". Default is "pearson".

interactive

A logical value indicating whether the output plot should be interactive (TRUE) or static (FALSE). Default is TRUE.

col_by

An optional character string specifying the name of the column in the data frame to be used for coloring points. Default is NULL.

Value

A ggplotly object (if interactive = TRUE) or a ggplot object (if interactive = FALSE) displaying the pairwise correlation plot with annotated correlation coefficients and optional coloring by the specified variable.

Examples

corrPairs(data = mtcars[,1:4],
         method = "pearson",
         interactive = TRUE,
         col_by = "cyl")