Skip to content
Prev 388112 / 398502 Next

About Pearson correlation functions

Hi

Maybe this is not directly related to R, but I appreciate you can help me with an idea. I use the following ggscatter function to plot a Pearson correlation Coefficient and it works fine. In the chart I see both R-value and P-value.


    ggscatter(mydata, x = "V1", y = "V2", add = "reg.line", conf.int = TRUE, cor.coef = TRUE, cor.method = "pearson")


On the other hand, when I use this command


    res <- cor.test(mydata$V1, mydata$V2, method = "pearson")


The R and P values are different from ggscatter.


I would like to know:


1- Why they are different?

2- How to print P and R values of ggscatter on terminal?



Regards,
Mahmood