How do I specify all numerical values only when calculating Pearson and then Spearman correlation matrices? And why can't the program find my dataframe that is sitting in the environment? When I run str(Data) it creates an output, yet the rest of the code doesn't work.
# Calculate the Pearson and then the Spearman correlation matrices using all numerical variables
str(Data)
#> Error in str(Data): object 'Data' not found
Data.cor = cor(Data)
#> Error in is.data.frame(x): object 'Data' not found
cor(Data, x,y, method = c("pearson"), use = "complete.obs")
#> Error in cor(Data, x, y, method = c("pearson"), use = "complete.obs"): unused argument (y)
cor(Data, x,y, method = c("spearman"), use = "complete.obs")
#> Error in cor(Data, x, y, method = c("spearman"), use = "complete.obs"): unused argument (y)
I didn't have your dataset, and hence used diamonds from ggplot2, as it has columns of many types. I used Filter to select the numeric columns, which is much faster than dplyr::select_if.