Learn R Programming

corrr (version 0.1.0)

focus: Focus on section of a correlation data frame.

Description

Convenience function to select a set of variables from a correlation matrix to keep as the columns, and exclude these or all other variables from the rows. This function will take a correlate correlation matrix, and expression(s) suited for dplyr::select(). The selected variables will remain in the columns, and these, or all other variables, will be excluded from the rows based on `same. For a complete list of methods for using this function, see select.

Usage

focus(x, ..., mirror = FALSE)

Arguments

x

cor_df. See correlate.

...

Comma separated list of unquoted expressions. You can treat variable names like they are positions. Use positive values to select variables; use negative values to drop variables.

mirror

Boolean. Whether to mirror the selected columns in the rows or not.

Value

A tbl or, if mirror = TRUE, a cor_df (see correlate).

Examples

Run this code
# NOT RUN {
x <- correlate(mtcars)
focus(x, mpg, cyl)  # Focus on correlations of mpg and cyl with all other variables
focus(x, -disp, - mpg, mirror = TRUE)  # Remove disp and mpg from columns and rows

x <- correlate(iris[-5])
focus(x, -matches("Sepal"))  # Focus on correlations of non-Sepal 
                             # variables with Sepal variables.
# }

Run the code above in your browser using DataLab