Learn R Programming

GGally (version 2.2.1)

ggmatrix_location: ggmatrix plot locations

Description

lifecycle::badge("experimental")

Usage

ggmatrix_location(pm, location = NULL, rows = NULL, cols = NULL)

Value

Data frame with columns c("row", "col") containing locations for the plot matrix

Arguments

pm

ggmatrix plot object

location
"all", TRUE

All row and col combinations

"none"

No row and column combinations

"upper"

Locations where the column value is higher than the row value

"lower"

Locations where the row value is higher than the column value

"diag"

Locations where the column value is equal to the row value

matrix or data.frame

matrix values will be converted into data.frames.

  • A data.frame with the exact column names c("row", "col")

  • A data.frame with the number of rows and columns matching the plot matrix object provided. Each cell will be tested for a "truthy" value to determine if the location should be kept.

rows

numeric vector of the rows to be used. Will be used with cols if location is NULL

cols

numeric vector of the cols to be used. Will be used with rows if location is NULL

Details

Convert many types of location values to a consistent data.frame of row and col values.

Examples

Run this code
pm <- ggpairs(tips, 1:3)

# All locations
ggmatrix_location(pm, location = "all")
ggmatrix_location(pm, location = TRUE)

# No locations
ggmatrix_location(pm, location = "none")

# "upper" triangle locations
ggmatrix_location(pm, location = "upper")

# "lower" triangle locations
ggmatrix_location(pm, location = "lower")

# "diag" locations
ggmatrix_location(pm, location = "diag")

# specific rows
ggmatrix_location(pm, rows = 2)

# specific columns
ggmatrix_location(pm, cols = 2)

# row and column combinations
ggmatrix_location(pm, rows = c(1, 2), cols = c(1, 3))

# matrix locations
mat <- matrix(TRUE, ncol = 3, nrow = 3)
mat[1, 1] <- FALSE
locs <- ggmatrix_location(pm, location = mat)
## does not contain the 1, 1 cell
locs

# Use the output of a prior ggmatrix_location
ggmatrix_location(pm, location = locs)

Run the code above in your browser using DataLab