plot_matrix {FieldSimR} | R Documentation |
Graphics for matrices
Description
Creates a heatmap of a symmetric matrix (e.g., correlation or covariance matrix).
Usage
plot_matrix(mat, order = FALSE, group.df = NULL, labels = TRUE)
Arguments
mat |
A symmetric matrix. |
order |
When |
group.df |
An optional data frame with columns containing the variable names followed by the group numbers.
When supplied, the heatmap is split into groups and then ordered (when |
labels |
When |
Value
A heatmap with x- and y-axes displaying the variable numbers, and colour gradient ranging from blue (low value) to red (high value).
Examples
# Display a random correlation matrix.
corA <- rand_cor_mat(
n = 10,
min.cor = -1,
max.cor = 1
)
# Define groups.
group_df <- data.frame(variable = 1:10, group = c(1, 1, 1, 1, 2, 2, 2, 3, 3, 4))
plot_matrix(
mat = corA,
order = TRUE,
group.df = group_df,
labels = TRUE
)
[Package FieldSimR version 1.3.0 Index]