[R] Building correlation matrix

Anyi Zhu anyi.zhu at gmail.com
Tue May 25 17:52:07 CEST 2010


Hi,

I am a novice with R, so pardon me if the question is a piece of cake
to some of you.

Say if I have a stream of data consisting of 3 columns, 1st column is
birth date, 2nd is death date and third is weight for each individual.

My ultimate goal is to be able to compute the correlation of weight
between any combination of two death dates, grouped by birth dates.

In order to do this, my plan is to be able to use a loop of some sorts
to split the data into n vectors, each vector consists of all birth
dates and weight for people who are dead on the same death date. Then
figure out the standard deviation and covariance of each of the
combination of the vectors, figure out the correlation and finally
bind them into a matrix (or at least a 3 column table: death date1,
death date 2, correlation).

The only problem is I know how to implement this in SQL/Excel but not in R.

Could someone please offer me some guidance on this? Thanks a lot!



More information about the R-help mailing list