summary.correlate: Summarizing Correlation Coefficient

View source: R/correlate.R

summary.correlateR Documentation

Summarizing Correlation Coefficient

Description

summary method for "correlate" class.

Usage

## S3 method for class 'correlate'
summary(object, ...)

Arguments

object

an object of class "correlate", usually, a result of a call to correlate().

...

further arguments passed to or from other methods.

Details

summary.correlate compares the correlation coefficient by variables.

See Also

correlate, plot.correlate.

Examples


library(dplyr)

# Correlation type is "generic" ===============================
# Correlation coefficients of all numerical variables
corr_tab <- correlate(heartfailure)
corr_tab

# summary correlate class 
mat <- summary(corr_tab)
mat

# Select the variable to compute
corr_tab <- correlate(heartfailure, creatinine, sodium)
corr_tab

# summary correlate class 
mat <- summary(corr_tab)
mat

# Correlation type is "group" ===============================
##-----------------------------------------------------------
# If the target variable is a categorical variable
# Using dplyr
corr_tab <- heartfailure %>%
  group_by(smoking, death_event) %>% 
  correlate() 

corr_tab

# summary correlate class 
mat <- summary(corr_tab)
mat

corr_tab <- heartfailure %>%
  group_by(smoking, death_event) %>% 
  correlate(creatinine) %>% 
  filter(abs(coef_corr) >= 0.2)

corr_tab

# summary correlate class 
mat <- summary(corr_tab)
mat

# connect DBMS
con_sqlite <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")

# copy heartfailure to the DBMS with a table named TB_HEARTFAILURE
copy_to(con_sqlite, heartfailure, name = "TB_HEARTFAILURE", overwrite = TRUE)

# Using pipes ---------------------------------
# Correlation coefficients of all numerical variables
corr_tab <- con_sqlite %>% 
  tbl("TB_HEARTFAILURE") %>% 
  correlate()

# summary correlate class 
mat <- summary(corr_tab)
mat

# Disconnect DBMS   
DBI::dbDisconnect(con_sqlite)



dlookr documentation built on July 9, 2023, 6:31 p.m.