[R-sig-teaching] Computing correlations

jones jones at reed.edu
Wed Apr 4 07:38:46 CEST 2012


That is really an r-help question, but easy, and I'm busy not
writing the lecture I should be writing:

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

albyn

On 4/3/12 4:31 PM, AbouEl-Makarim Aboueissa wrote:
> Dear All:
>
> I have another silly question. How I can compute the correlations of
> two groups of variables. 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)
> x2<-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)
>
>
> x2        corr(x2,y1)       corr(x2,y2)         corr(x2,y3)
>
>
> x3        corr(x3,y1)       corr(x3,y2)         corr(x3,y3)
>
>
>
>
> 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