| title: “Descriptive Statistics: Scaling and Correlations” output: html_notebook |
r #Try it out yourself #Define a vector with Grumpiness scores of you and your friends and find the z score for your self X = c(25, 30, 35, 40, 45) z = (X - mean(X)) / sd(X) print (z) |
[1] -1.2649111 -0.6324555 0.0000000 0.6324555 1.2649111 |
| #### Correlation |
| So far we have focused entirely on how to construct descriptive statistics for a single variable. We haven’t talked about how to describe the relationships between variables in the data. To do that, we want to talk mostly about the correlation between variables. |
| ```r setwd(“/Users/kunaalgautam17/BSE658/Module 3/Datasets”) |
| #Let’s load some data load( “parenthood.Rdata” ) ``` |
r install.packages("psych") |
| ``` |
| There is a binary version available but the source version is later: ``` |
| ``` installing the source package ‘psych’ |
| trying URL ‘https://cran.rstudio.com/src/contrib/psych_2.4.6.26.tar.gz’ Content type ‘application/x-gzip’ length 1312211 bytes (1.3 MB) ================================================== downloaded 1.3 MB |
| * installing source package ‘psych’ … ** package ‘psych’ successfully unpacked and MD5 sums checked ** using staged installation ** R ** data *** moving datasets to lazyload DB ** inst ** byte-compile and prepare package for lazy loading ** help *** installing help indices ** building package indices ** installing vignettes ** testing if installed package can be loaded from temporary location ** testing if installed package can be loaded from final location ** testing if installed package keeps a record of temporary installation path * DONE (psych) |
| The downloaded source packages are in ‘/private/var/folders/mp/z6f57qs50qz0r6clww_9z5tr0000gn/T/RtmpnkyJjJ/downloaded_packages’ ``` |
| ```r library(psych) |
| #Try describe() for the above dataframe describe(parenthood) ``` |
r #Let's also take a graphical look at the data hist(parenthood$dan.sleep) |
| ```r |
| #Try plotting for the other 2 variables hist(parenthood$baby.sleep) ``` |
r hist(parenthood$dan.grump) |
| A simple way to plot these scatter plots is to use the scatterplot() function in the car package. |
| Let’s load the package and get started. |
r install.packages("car") |
also installing the dependencies ‘nloptr’, ‘pbkrtest’, ‘lme4’ |
| ``` |
| There are binary versions available but the source versions are later: ``` |
r Yes |
trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.2/car_3.1-2.tgz' Content type 'application/x-gzip' length 1711787 bytes (1.6 MB) ================================================== downloaded 1.6 MB |
| ``` |
| The downloaded binary packages are in /var/folders/mp/z6f57qs50qz0r6clww_9z5tr0000gn/T//RtmpnkyJjJ/downloaded_packages ``` |
| ``` installing the source packages ‘nloptr’, ‘pbkrtest’, ‘lme4’ |
| trying URL ‘https://cran.rstudio.com/src/contrib/nloptr_2.1.1.tar.gz’ Content type ‘application/x-gzip’ length 2236635 bytes (2.1 MB) ================================================== downloaded 2.1 MB |
| trying URL ‘https://cran.rstudio.com/src/contrib/pbkrtest_0.5.3.tar.gz’ Content type ‘application/x-gzip’ length 59013 bytes (57 KB) ================================================== downloaded 57 KB |
| trying URL ‘https://cran.rstudio.com/src/contrib/lme4_1.1-35.5.tar.gz’ Content type ‘application/x-gzip’ length 3300116 bytes (3.1 MB) ================================================== downloaded 3.1 MB |
| * installing source package ‘nloptr’ … ** package ‘nloptr’ successfully unpacked and MD5 sums checked ** using staged installation ``` |
| ``` checking whether the C++ compiler works… yes checking for C++ compiler default output file name… a.out checking for suffix of executables… checking whether we are cross compiling… no checking for suffix of object files… o checking whether the compiler supports GNU C++… yes checking whether clang++ -arch arm64 -std=gnu++14 accepts -g… yes checking for clang++ -arch arm64 -std=gnu++14 option to enable C++11 features… none needed checking how to run the C++ preprocessor… clang++ -arch arm64 -std=gnu++14 -E checking whether the compiler supports GNU C++… (cached) yes checking whether clang++ -arch arm64 -std=gnu++14 accepts -g… (cached) yes checking for clang++ -arch arm64 -std=gnu++14 option to enable C++11 features… (cached) none needed checking for pkg-config… no checking for cmake… no |
| —————— CMAKE NOT FOUND ——————– |
| CMake was not found on the PATH. Please install CMake: |
| - sudo yum install cmake (Fedora/CentOS; inside a terminal) - sudo apt install cmake (Debian/Ubuntu; inside a terminal). - sudo pacman -S cmake (Arch Linux; inside a terminal). - brew install –cask cmake (MacOS; inside a terminal with Homebrew) - sudo port install cmake (MacOS; inside a terminal with MacPorts) |
| Alternatively install CMake from: https://cmake.org/ |
<!-- rnb-output-end -->
<!-- rnb-output-begin eyJkYXRhIjoiRVJST1I6IGNvbmZpZ3VyYXRpb24gZmFpbGVkIGZvciBwYWNrYWdlIOKAmG5sb3B0cuKAmVxuKiByZW1vdmluZyDigJgvTGlicmFyeS9GcmFtZXdvcmtzL1IuZnJhbWV3b3JrL1ZlcnNpb25zLzQuMi1hcm02NC9SZXNvdXJjZXMvbGlicmFyeS9ubG9wdHLigJlcbiJ9 -->
ERROR: configuration failed for package ‘nloptr’ * removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/nloptr’
<!-- rnb-output-end -->
<!-- rnb-output-begin eyJkYXRhIjoiV2FybmluZyBpbiBpbnN0YWxsLnBhY2thZ2VzIDpcbiAgaW5zdGFsbGF0aW9uIG9mIHBhY2thZ2Ug4oCYbmxvcHRy4oCZIGhhZCBub24temVybyBleGl0IHN0YXR1c1xuIn0= -->
Warning in install.packages : installation of package ‘nloptr’ had non-zero exit status
<!-- rnb-output-end -->
<!-- rnb-output-begin eyJkYXRhIjoiRVJST1I6IGRlcGVuZGVuY3kg4oCYbmxvcHRy4oCZIGlzIG5vdCBhdmFpbGFibGUgZm9yIHBhY2thZ2Ug4oCYbG1lNOKAmVxuKiByZW1vdmluZyDigJgvTGlicmFyeS9GcmFtZXdvcmtzL1IuZnJhbWV3b3JrL1ZlcnNpb25zLzQuMi1hcm02NC9SZXNvdXJjZXMvbGlicmFyeS9sbWU04oCZXG4ifQ== -->
ERROR: dependency ‘nloptr’ is not available for package ‘lme4’ * removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/lme4’
<!-- rnb-output-end -->
<!-- rnb-output-begin eyJkYXRhIjoiV2FybmluZyBpbiBpbnN0YWxsLnBhY2thZ2VzIDpcbiAgaW5zdGFsbGF0aW9uIG9mIHBhY2thZ2Ug4oCYbG1lNOKAmSBoYWQgbm9uLXplcm8gZXhpdCBzdGF0dXNcbiJ9 -->
Warning in install.packages : installation of package ‘lme4’ had non-zero exit status
<!-- rnb-output-end -->
<!-- rnb-output-begin eyJkYXRhIjoiRVJST1I6IGRlcGVuZGVuY3kg4oCYbG1lNOKAmSBpcyBub3QgYXZhaWxhYmxlIGZvciBwYWNrYWdlIOKAmHBia3J0ZXN04oCZXG4qIHJlbW92aW5nIOKAmC9MaWJyYXJ5L0ZyYW1ld29ya3MvUi5mcmFtZXdvcmsvVmVyc2lvbnMvNC4yLWFybTY0L1Jlc291cmNlcy9saWJyYXJ5L3Bia3J0ZXN04oCZXG4ifQ== -->
ERROR: dependency ‘lme4’ is not available for package ‘pbkrtest’ * removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/pbkrtest’
<!-- rnb-output-end -->
<!-- rnb-output-begin eyJkYXRhIjoiV2FybmluZyBpbiBpbnN0YWxsLnBhY2thZ2VzIDpcbiAgaW5zdGFsbGF0aW9uIG9mIHBhY2thZ2Ug4oCYcGJrcnRlc3TigJkgaGFkIG5vbi16ZXJvIGV4aXQgc3RhdHVzXG4ifQ== -->
Warning in install.packages : installation of package ‘pbkrtest’ had non-zero exit status
<!-- rnb-output-end -->
<!-- rnb-output-begin eyJkYXRhIjoiXG5UaGUgZG93bmxvYWRlZCBzb3VyY2UgcGFja2FnZXMgYXJlIGluXG5cdOKAmC9wcml2YXRlL3Zhci9mb2xkZXJzL21wL3o2ZjU3cXM1MHF6MHI2Y2x3d185ejV0cjAwMDBnbi9UL1J0bXBua3lKakovZG93bmxvYWRlZF9wYWNrYWdlc+KAmVxuIn0= -->
The downloaded source packages are in ‘/private/var/folders/mp/z6f57qs50qz0r6clww_9z5tr0000gn/T/RtmpnkyJjJ/downloaded_packages’
<!-- rnb-output-end -->
<!-- rnb-source-begin eyJkYXRhIjoiYGBgclxuaW5zdGFsbC5wYWNrYWdlcyhcIlJjcHBcIilcbmBgYCJ9 -->
```r
install.packages("Rcpp")
There is a binary version available but the source version is later:
Yes
installing the source package ‘Rcpp’
trying URL 'https://cran.rstudio.com/src/contrib/Rcpp_1.0.13.tar.gz'
Content type 'application/x-gzip' length 3435344 bytes (3.3 MB)
==================================================
downloaded 3.3 MB
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/ -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c api.cpp -o api.o
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/ -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c attributes.cpp -o attributes.o
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/ -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c barrier.cpp -o barrier.o
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/ -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c date.cpp -o date.o
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/ -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c module.cpp -o module.o
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/ -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c rcpp_init.cpp -o rcpp_init.o
clang++ -arch arm64 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o Rcpp.so api.o attributes.o barrier.o date.o module.o rcpp_init.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: -single_module is obsolete
ld: warning: -multiply_defined is obsolete
installing to /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/00LOCK-Rcpp/00new/Rcpp/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (Rcpp)
The downloaded source packages are in
‘/private/var/folders/mp/z6f57qs50qz0r6clww_9z5tr0000gn/T/RtmpnkyJjJ/downloaded_packages’
library(car)
Loading required package: carData
Attaching package: ‘car’
The following object is masked from ‘package:psych’:
logit
scatterplot( dan.grump ~ dan.sleep, data = parenthood, regLine = FALSE, smooth = FALSE)
scatterplot
function (x, ...)
{
UseMethod("scatterplot")
}
<bytecode: 0x110744a58>
<environment: namespace:car>
#Plot a scatter plot for baby.sleep and dan.grump variables
scatterplot( baby.sleep ~ dan.grump, data = parenthood, regLine = FALSE, smooth = FALSE)
scatterplot
function (x, ...)
{
UseMethod("scatterplot")
}
<bytecode: 0x110744a58>
<environment: namespace:car>
Just by plain observation and comparison, you can see that the relationship is qualitatively the same in both cases: more sleep equals less grump! However, it’s also pretty obvious that the relationship between dan.sleep and dan.grump is stronger than the relationship between baby.sleep and dan.grump.
But what about the plot between baby.sleep and dan.sleep?
#Plot baby sleep and dan sleep here
scatterplot( baby.sleep ~ dan.sleep, data = parenthood, regLine = FALSE, smooth = FALSE)
Is the direction of this plot same as the earlier plots? What about strength? - Direction: The last plot shows a positive correlation, unlike the earlier plots which show a negative correlation. - Strength: The last plot has a moderate positive correlation, weaker than the first plot but similar in strength to the second plot.
cor(x = parenthood$dan.sleep, y = parenthood$dan.grump)
[1] -0.903384
#Try giving the entire dataframe 'parenthood' as input in cor()
cor_matrix <- cor(parenthood)
print (cor_matrix)
dan.sleep baby.sleep dan.grump day
dan.sleep 1.00000000 0.62794934 -0.90338404 -0.09840768
baby.sleep 0.62794934 1.00000000 -0.56596373 -0.01043394
dan.grump -0.90338404 -0.56596373 1.00000000 0.07647926
day -0.09840768 -0.01043394 0.07647926 1.00000000
What did you find? The correlation matrix shows that Dan’s sleep is
strongly negatively correlated with Dan’s grumpiness
(-0.903), and there is a moderate positive correlation
between Dan’s sleep and Baby’s sleep (0.628). The day
variable has weak or negligible correlations with the other variables.
##### What does r = 0.4 mean? A r = 0.4 indicates a moderate positive
correlation, meaning that as one variable increases, the other tends to
increase as well, but the relationship is not very strong. It really
depends on what you want to use the data for, and on how strong the
correlations in your field tend to be.
Now let’s take a look at this data called “Anscombe’s Quartet”
load( "anscombesquartet.Rdata" )
cor( X1, Y1 )
[1] 0.8164205
cor( X2, Y2 )
[1] 0.8162365
cor (X3, Y3)
[1] 0.8162867
cor (X4, Y4)
[1] 0.8165214
Were the correlation coefficients same? similar but not same
Now try plotting them.
par(mfrow=c(2,2)) # Arrange plots in a 2x2 grid
plot(X1, Y1, main="Scatterplot X1 vs Y1")
plot(X2, Y2, main="Scatterplot X2 vs Y2")
plot(X3, Y3, main="Scatterplot X3 vs Y3")
plot(X4, Y4, main="Scatterplot X4 vs Y4")
Therefore, remember to always look at the scatterplot before attaching any interpretation to the data!
If we have to properly define the role of Pearson’s coefficient, we can say that it actually measures the strength of the linear relationship between two variables. In other words, it gives a measure of the extent to which the data all tend to fall on a single, perfectly straight line.
But let’s take a look at another dataset and find correlation between its variables.
setwd("/Users/kunaalgautam17/BSE658/Module 3/Datasets")
load( "effort.Rdata" )
effort
cor( effort$hours, effort$grade )
[1] 0.909402
If you plot this -
scatterplot(effort$hours, effort$grade, regLine = TRUE, smooth = FALSE)
The correlation r = 0.91 we get above doe snot represent the actual relationship the plot is depicting. What we’re looking for is something that captures the fact that there is a perfect ordinal relationship here. That is, if student 1 works more hours than student 2, then we can guarantee that student 1 will get the better grade.
If we’re looking for ordinal relationships, all we have to do is treat the data as if it were ordinal scale! So, instead of measuring effort in terms of “hours worked”, let’s rank all 10 of the students in order of hours worked. That is, student 1 did the least work out of anyone (2 hours) so they get the lowest rank (rank = 1). Student 4 was the next laziest, putting in only 6 hours of work in over the whole semester, so they get the next lowest rank (rank = 2).
hours.rank <- rank( effort$hours ) # rank students by hours worked
grade.rank <- rank( effort$grade ) # rank students by grade received
#Now try cor() function for these
cor( hours.rank, grade.rank )
[1] 1
Now the correlation coefficient we get is different from the Perason’s correlation coefficient r we got earlier. This new correlation coefficient that we got is called ‘Spearman’s Correlation Coefficient’, denoted by \(\rho\).
#Execute this and compare with the correlation coefficient we got above
cor( effort$hours, effort$grade, method = "spearman")
[1] 1
We’ve seen in earlier lectures that there could be missing values in
data which are represented by NA in R. One easy way to
remove them is using na.rm = TRUE as argument in many
functions.
But what if we have missing values in a dataframe where we have to find correlations across variables.
Let’s look at such a dataset.
load( "parenthood2.Rdata" )
print( parenthood2 )
describe( parenthood2 )
describe_output <- describe(parenthood2)
missing_values <- colSums(is.na(parenthood2))
print(missing_values)
dan.sleep baby.sleep dan.grump day
9 11 8 0
total_days <- nrow(parenthood2)
print(paste("Total number of days (rows):", total_days))
[1] "Total number of days (rows): 100"
n_values <- describe_output$n
comparison <- total_days - n_values
print(comparison)
[1] 9 11 8 0
#Check how many missing values are there for each variable - compare the values in 'n' with the number of days.
Now, let’s try finding correlations for this dataframe.
cor(parenthood2)
dan.sleep baby.sleep dan.grump day
dan.sleep 1 NA NA NA
baby.sleep NA 1 NA NA
dan.grump NA NA 1 NA
day NA NA NA 1
In order top overcome this problem, we can use use as an
argument in the cor() function. Try out the following.
cor(parenthood2, use = "complete.obs")
dan.sleep baby.sleep dan.grump day
dan.sleep 1.00000000 0.6394985 -0.89951468 0.06132891
baby.sleep 0.63949845 1.0000000 -0.58656066 0.14555814
dan.grump -0.89951468 -0.5865607 1.00000000 -0.06816586
day 0.06132891 0.1455581 -0.06816586 1.00000000
cor(parenthood2, use = "pairwise.complete.obs")
dan.sleep baby.sleep dan.grump day
dan.sleep 1.00000000 0.61472303 -0.903442442 -0.076796665
baby.sleep 0.61472303 1.00000000 -0.567802669 0.058309485
dan.grump -0.90344244 -0.56780267 1.000000000 0.005833399
day -0.07679667 0.05830949 0.005833399 1.000000000
When we choose use = "complete.obs", R will completely
ignore all cases (i.e., all rows in our parenthood2 data frame) that
have any missing values at all. For eg., if you choose use =
“complete.obs” R will ignore that row completely: that is, even when
it’s trying to calculate the correlation between dan.sleep and
dan.grump, observation 1 will be ignored, because the value of
baby.sleep is missing for that observation.
Whereas when we set use = "pairwise.complete.obs" R only
looks at the variables that it’s trying to correlate when determining
what to drop. So, for instance, since the only missing value for
observation 1 of parenthood2 is for baby.sleep R will only drop
observation 1 when baby.sleep is one of the variables involved: and so R
keeps observation 1 when trying to correlate dan.sleep and
dan.grump.
The above operation can also be performed by another function called
correlate() in lsr package.
Try it out.
#Try correlate() for parenthood2 here
install.packages("corrr")
also installing the dependencies ‘vegan’, ‘seriation’
There are binary versions available but the source versions are later:
Yes
trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.2/corrr_0.4.4.tgz'
Content type 'application/x-gzip' length 481435 bytes (470 KB)
==================================================
downloaded 470 KB
The downloaded binary packages are in
/var/folders/mp/z6f57qs50qz0r6clww_9z5tr0000gn/T//RtmpnkyJjJ/downloaded_packages
installing the source packages ‘vegan’, ‘seriation’
trying URL 'https://cran.rstudio.com/src/contrib/vegan_2.6-8.tar.gz'
Content type 'application/x-gzip' length 1499798 bytes (1.4 MB)
==================================================
downloaded 1.4 MB
trying URL 'https://cran.rstudio.com/src/contrib/seriation_1.5.6.tar.gz'
Content type 'application/x-gzip' length 954722 bytes (932 KB)
==================================================
downloaded 932 KB
* installing *source* package ‘vegan’ ...
** package ‘vegan’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c data2hill.c -o data2hill.o
/opt/R/arm64/bin/gfortran -mtune=native -fno-optimize-sibling-calls -fPIC -Wall -g -O2 -c decorana.f -o decorana.o
make: /opt/R/arm64/bin/gfortran: No such file or directory
make: *** [decorana.o] Error 1
ERROR: compilation failed for package ‘vegan’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/vegan’
Warning in install.packages :
installation of package ‘vegan’ had non-zero exit status
ERROR: dependency ‘vegan’ is not available for package ‘seriation’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/seriation’
Warning in install.packages :
installation of package ‘seriation’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/mp/z6f57qs50qz0r6clww_9z5tr0000gn/T/RtmpnkyJjJ/downloaded_packages’
library(corrr)
correlation_matrix <- correlate(parenthood2)
Correlation computed with
• Method: 'pearson'
• Missing treated using: 'pairwise.complete.obs'
print(correlation_matrix)
NA
install.packages("ggcorrplot")
trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.2/ggcorrplot_0.1.4.1.tgz'
Content type 'application/x-gzip' length 28580 bytes (27 KB)
==================================================
downloaded 27 KB
The downloaded binary packages are in
/var/folders/mp/z6f57qs50qz0r6clww_9z5tr0000gn/T//RtmpnkyJjJ/downloaded_packages
library(ggcorrplot)
Loading required package: ggplot2
Warning: package ‘ggplot2’ was built under R version 4.2.3
Attaching package: ‘ggplot2’
The following objects are masked from ‘package:psych’:
%+%, alpha
# Compute a correlation matrix
data(mtcars)
corr <- round(cor(mtcars), 1)
head(corr[, 1:6])
mpg cyl disp hp drat wt
mpg 1.0 -0.9 -0.8 -0.8 0.7 -0.9
cyl -0.9 1.0 0.9 0.8 -0.7 0.8
disp -0.8 0.9 1.0 0.8 -0.7 0.9
hp -0.8 0.8 0.8 1.0 -0.4 0.7
drat 0.7 -0.7 -0.7 -0.4 1.0 -0.7
wt -0.9 0.8 0.9 0.7 -0.7 1.0
# Compute a matrix of correlation p-values
p.mat <- cor_pmat(mtcars)
head(p.mat[, 1:4])
mpg cyl disp hp
mpg 0.000000e+00 6.112687e-10 9.380327e-10 1.787835e-07
cyl 6.112687e-10 0.000000e+00 1.802838e-12 3.477861e-09
disp 9.380327e-10 1.802838e-12 0.000000e+00 7.142679e-08
hp 1.787835e-07 3.477861e-09 7.142679e-08 0.000000e+00
drat 1.776240e-05 8.244636e-06 5.282022e-06 9.988772e-03
wt 1.293959e-10 1.217567e-07 1.222320e-11 4.145827e-05
ggcorrplot(corr)
ggcorrplot(corr, method = "circle")
ggcorrplot(corr, hc.order = TRUE, outline.col = "white")
ggcorrplot(corr, hc.order = TRUE, type = "lower",
outline.col = "white")
ggcorrplot(corr, hc.order = TRUE, type = "upper",
outline.col = "white")
ggcorrplot(corr, hc.order = TRUE, type = "lower",
outline.col = "white",
ggtheme = ggplot2::theme_gray,
colors = c("#6D9EC1", "white", "#E46726"))
ggcorrplot(corr, hc.order = TRUE, type = "lower",
lab = TRUE)
ggcorrplot(corr, hc.order = TRUE,
type = "lower", p.mat = p.mat)
ggcorrplot(corr, p.mat = p.mat, hc.order = TRUE,
type = "lower", insig = "blank")