correallyPlot: Create correally correlation plot

Description Usage Arguments Value Examples

View source: R/correally.R

Description

This function creates an interactive visualization of a correlation matrix. It is based on the R implementation of plotly.js, an (MIT licensed) web-based interactive charting library. It provides a clean implementation for plotting correlation matrices, easy use of different color schemes (Base R colors, Hex colors, RColorBrewer palettes as well as support for viridisLite). It also provides coloring options for backgrounds, grids and fonts matching different shinythemes.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
correallyPlot(
  data,
  mask = FALSE,
  color = "RdBu",
  theme = "default",
  width = NULL,
  height = NULL,
  keepRatio = TRUE,
  showGrid = TRUE
)

Arguments

data

A matrix or data frame containing a correlation matrix. Must be numeric and symmetric.

mask

A logical scalar. If TRUE, removes the everything above and including the diagonal. Defaults to FALSE.

color

Either a vector of Base R colors (e.g. "red", "blue"), a vector of colors in hexadecimal #RRGGBB# format, a colorbrewer2.org palette name (e.g. "YlOrRd", "BrBG") or a viridis palette name (e.g. "viridis", "magma", "inferno"). Defaults to "RdBu".

theme

A character string of length 1 defining the name of a shinythemes template. Formatting will be applied to the background, gridline color, colorbar framing and font color. Defaults to the "default" theme.

width

Width in pixels (optional, defaults to automatic sizing).

height

Height in pixels (optional, defaults to automatic sizing).

keepRatio

A logical scalar. If TRUE, keeps a 1:1 ratio between x and y axis size. Defaults to TRUE.

showGrid

A logical scalar. If TRUE, displays gridlines. Defaults to TRUE.

Value

Returns a plotly object.

Examples

1
2
3
4
5
6
7
8
data = cor(mtcars[,c(1,3:7)])

correallyPlot(data)
correallyPlot(data, mask = TRUE)

correallyPlot(data, mask = TRUE, color = "viridis", theme = "slate")

correallyPlot(data, mask = TRUE, width = 700, height = 500, keepRatio = FALSE, showGrid = FALSE)

addiversitas/correally documentation built on Oct. 4, 2020, 12:14 a.m.