corrr (version 0.4.0)

stretch: Stretch correlation data frame into long format.

Description

stretch is a specified implementation of tidyr::gather() to be applied to a correlation data frame. It will gather the columns into a long-format data frame. The rowname column is handled automatically.

Usage

stretch(x, na.rm = FALSE, remove.dups = FALSE)

Arguments

x

cor_df. See correlate.

na.rm

Boolean. Whether rows with an NA correlation (originally the matrix diagonal) should be dropped? Will automatically be set to TRUE if mirror is FALSE.

remove.dups

Removes duplicate entries, without removing all NAs

Value

tbl with three columns (x and y variables, and their correlation)

Examples

Run this code
# NOT RUN {
x <- correlate(mtcars)
stretch(x)  # Convert all to long format
stretch(x, na.rm = FALSE)  # omit NAs (diagonal in this case)

x <- shave(x)  # use shave to set upper triangle to NA and then...
stretch(x, na.rm = FALSE)  # omit all NAs, therefore keeping each
                             # correlation only once.
# }

Run the code above in your browser using DataCamp Workspace