correlation matrix in R

Hi everyone, I would like to create a correlation matrix using the variables of a dataset, anyone can explain me what I have to do? Thanks

this is what I do for now, but I only can find the correlation but no the correlation matrix:

install.packages("ISLR")
library(ISLR)
data(Credit)

cor(Credit$Income, Credit$Limit)

update, I tried to do with this formula, anyone can tell me if it's correct?

reg1<-lm (Credit$Balance~Credit$Income,data=Credit)
summary (reg1)

this is the script

Call:
lm(formula = Credit$Balance ~ Credit$Income, data = Credit)

Residuals:
Min 1Q Median 3Q Max
-803.64 -348.99 -54.42 331.75 1100.25

Coefficients
*Estimate Std. Error t value Pr(>|t|) **
(Intercept) 246.5148 33.1993 7.425 6.9e-13 *****
Credit$Income 6.0484 0.5794 10.440 < 2e-16 *****
---
Signif. codes: 0 ‘
’ 0.001 ‘
’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 407.9 on 398 degrees of freedom
Multiple R-squared: 0.215, Adjusted R-squared: 0.213
F-statistic: 109 on 1 and 398 DF, p-value: < 2.2e-16

Try this:

Credit %>% 
   psych::pairs.panels(method = "spearman")

You need to install psych

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.