cor_select.Rd
Subset Correlation Matrix
cor_select(x, ..., vars = NULL)
x | a correlation matrix. Particularly, an object of class |
---|---|
... | One or more unquoted expressions (or variable names) separated by commas. Used to select variables of interest. |
vars | a character vector containing the variable names of interest. |
a data frame
cor_mat()
, pull_triangle()
, replace_triangle()
# Compute correlation matrix #:::::::::::::::::::::::::::::::::::::::::: cor.mat <- mtcars %>% select(mpg, disp, hp, drat, wt, qsec) %>% cor_mat() # Subsetting correlation matrix #:::::::::::::::::::::::::::::::::::::::::: # Select some variables of interest cor.mat %>% cor_select(mpg, drat, wt)#> # A tibble: 3 x 4 #> rowname mpg drat wt #> <chr> <dbl> <dbl> <dbl> #> 1 mpg 1 0.68 -0.87 #> 2 drat 0.68 1 -0.71 #> 3 wt -0.87 -0.71 1# Remove variables cor.mat %>% cor_select(-mpg, -wt)#> # A tibble: 4 x 5 #> rowname disp hp drat qsec #> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 disp 1 0.79 -0.71 -0.43 #> 2 hp 0.79 1 -0.45 -0.71 #> 3 drat -0.71 -0.45 1 0.091 #> 4 qsec -0.43 -0.71 0.091 1