| inspect_cor {inspectdf} | R Documentation | 
Tidy correlation coefficients for numeric dataframe columns
Description
Summarise and compare Pearson, Kendall and Spearman correlations for numeric columns in one, two or grouped dataframes.
Usage
inspect_cor(df1, df2 = NULL, method = "pearson", with_col = NULL, alpha = 0.05)
Arguments
df1 | 
 A data frame.  | 
df2 | 
 An optional second data frame for comparing correlation 
coefficients.  Defaults to   | 
method | 
 a character string indicating which type of correlation coefficient to use, one 
of   | 
with_col | 
 Character vector of column names to calculate correlations with all other numeric 
features.  The default   | 
alpha | 
 Alpha level for correlation confidence intervals. Defaults to 0.05.  | 
Details
When df2 = NULL, a tibble containing correlation coefficients for df1 is 
returned:
-  
col_1,co1_2character vectors containing names of numeric columns indf1. -  
corrthe calculated correlation coefficient. -  
p_valuep-value associated with a test where the null hypothesis is that the numeric pair have 0 correlation. -  
lower,upperlower and upper values of the confidence interval for the correlations. -  
pcnt_nnathe number of pairs of observations that were non missing for each pair of columns. The correlation calculation used byinspect_cor()uses only pairwise complete observations. 
If df1 has class grouped_df, then correlations will be calculated within the grouping levels 
and the tibble returned will have an additional column corresponding to the group labels.
When both df1 and df2 are specified, the tibble returned contains
a comparison of the correlation coefficients across pairs of columns common to both 
dataframes.
-  
col_1,co1_2character vectors containing names of numeric columns in eitherdf1ordf2. -  
corr_1,corr_2numeric columns containing correlation coefficients fromdf1anddf2, respectively. -  
p_valuep-value associated with the null hypothesis that the two correlation coefficients are the same. Small values indicate that the true correlation coefficients differ between the two dataframes. 
Note that confidence intervals for kendall and spearman assume a normal sampling
distribution for the Fisher z-transform of the correlation.
Value
A tibble summarising and comparing the correlations for each numeric column in one or a pair of data frames.
Examples
# Load dplyr for starwars data & pipe
library(dplyr)
# Single dataframe summary
inspect_cor(starwars)
# Only show correlations with 'mass' column
inspect_cor(starwars, with_col = "mass")
# Paired dataframe summary
inspect_cor(starwars, starwars[1:10, ])
# NOT RUN - change in correlation over time
# library(dplyr)
# tech_grp <- tech %>% 
#         group_by(year) %>%
#         inspect_cor()
# tech_grp %>% show_plot()