ggpairs correlation method

Hi,

I am trying to run the "ggpairs" function to plot the correlation between different variables ("a" database) and differentiate by groups ("group").
The problem is that I have to apply the spearman method but I can't change the default method.

I appreciate your help to solve this problem

This is the line I execute
ggpairs(a, method = c("everything", "spearman"), mapping = aes(color = group, alpha = 0.5)) + theme_bw()

And this is the warning that comes out when executing the line:
Extra arguments: "method" are being ignored. If these are aesthetics, display them using the 'mapping' variable inside ggpairs with ggplot2::aes or ggplot2::aes_string.

Here is an example of displaying Spearman correlation values with ggpairs.

library(GGally)
#> Loading required package: ggplot2
#> Registered S3 method overwritten by 'GGally':
#>   method from   
#>   +.gg   ggplot2
DF <- data.frame(A = rnorm(20), B = rnorm(20),C = rnorm(20))
cor(DF, method = "spearman") #only for comparing to the plot values
#>            A           B           C
#> A 1.00000000  0.08721805  0.29172932
#> B 0.08721805  1.00000000 -0.07518797
#> C 0.29172932 -0.07518797  1.00000000
ggpairs(DF, 
        upper = list(continuous = wrap(ggally_cor, method = "spearman")))

Created on 2023-10-06 with reprex v2.0.2

3 Likes

This topic was automatically closed 7 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.