focus: Focus on section of a correlation data frame.

Description Usage Arguments Value Examples

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

1
2
3
focus(x, ..., mirror = FALSE)

focus_(x, ..., .dots, mirror)

Arguments

x

cor_df. See correlate.

...

One or more unquoted expressions separated by commas. You can treat variable names like they are positions, so you can use expressions like x:y to select ranges of variables.

Positive values select variables; negative values drop variables. If the first expression is negative, select() will automatically start with all variables.

Use named arguments, e.g. new_name = old_name, to rename selected variables.

The arguments in ... are automatically quoted and evaluated in a context where column names represent column positions. They also support unquoting and splicing. See vignette("programming") for an introduction to these concepts.

See select helpers for more details and examples about tidyselect helpers such as starts_with(), everything(), ...

mirror

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

.dots

Use focus_ to do standard evaluations. See select.

Value

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

Examples

1
2
3
4
5
6
7
8
library(dplyr)
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.

drsimonj/corrr documentation built on May 15, 2019, 2:52 p.m.