[R-sig-teaching] Computing correlations including the p values

Ista Zahn istazahn at gmail.com
Wed Apr 4 02:05:57 CEST 2012


Hi,

For the correlations you just need to understand how matrix indecies work in R:

cor(cbind(x1, x2, x3, y1, y2, y3))[4:6, 1:3]

I'll leave it to you to figure out the p values part.

Best,
Ista

On Tue, Apr 3, 2012 at 7:48 PM, AbouEl-Makarim Aboueissa
<aaboueissa at usm.maine.edu> wrote:
> Dear All: (revise of the previous message)
>
> I have another silly question. How I can compute the correlations of two groups of variables including the p values. For example how to compute the correlations of the X's with Y's only of these two groups of variables
>
> x1<-c(12,3,45,32,34,56,7,89)
> x2<-c(6,8,9,6,7,44,33,22)
> x3<-c(45,7,6,89,23,45,67,22)
>
> y1<-c(21,43,77,32,23,45,78,90)
> y2<-c(32,56,78,90,34,23,11,23)
> y3<-c(8,90,34,68,72,17,27,35)
>
>
> This what I need to get:
>
>                     y1                  y2                  y3
>
> x1        corr(x1,y1)       corr(x1,y2)         corr(x1,y3)
>            p value              p value             p value
>
> x2        corr(x2,y1)       corr(x2,y2)         corr(x2,y3)
>             p value           p value                p value
>
> x3        corr(x3,y1)       corr(x3,y2)         corr(x3,y3)
>              p value           p value               p value
>
>
>
> Thank you very much
> abou
>
>
> ==========================
> AbouEl-Makarim Aboueissa, Ph.D.
> Associate Professor of Statistics
> Graduate Program Coordinator
> Department of Mathematics & Statistics
> University of Southern Maine
> 96 Falmouth Street
> P.O. Box 9300
> Portland, ME 04104-9300
> USA
>
>
> Tel: (207) 228-8389
> Fax: (207) 780-5607
> Email: aaboueissa at usm.maine.edu
>          aboueiss at yahoo.com
>
> Office: 301C Payson Smith
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-teaching at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching



More information about the R-sig-teaching mailing list