0

R version 3.5.1. I want to create a correlation matrix with a Data frame that goes like this:

BGI      WINDSPEED  SLOPE 
4277.2   4.23        7.54
4139.8   5.25        8.63
4652.9   3.59        6.54
3942.6   4.42        10.05

I put that as an example but I have more than 20 columns and over 40,000 entries.

I tried using the following codes

corrplot(cor(Site.2),method = "color",outline="white")

Matrix_Site=cor(Site.2,method=c("spearman"))

but every time, the same warning appears:

Error in cor(Site.2) : 'x' must be numeric

I would like to correlate every variable of the data frame with each other and create a graph and a table with it, similar to this.

NelsonGon
  • 13,015
  • 7
  • 27
  • 57
Cecilia P
  • 29
  • 2
  • 1
    Usually this error happens when one of your columns is not numeric. Try `str(Site.2)` to see if youve forgotten to change them all to numeric. Also, check for missing values. – InfiniteFlash Jul 09 '19 at 16:11
  • 1
    **Self promotion**: Is this what you want to achieve? `manymodelr::get_var_corr_(df,method="spearman")` – NelsonGon Jul 09 '19 at 16:11

0 Answers0