Date: Mon, 4 Jan 2010 07:49:17 -0800 (PST)
From: Zongshan Li <zongshan_li at yahoo.com>
Subject: [R-sig-eco] How to index different datasets in the common
period based on their same column?
To: r-sig-ecology at r-project.org
Message-ID: <587513.23865.qm at web114015.mail.gq1.yahoo.com>
Content-Type: text/plain
Dear the friends of R-Ecology:
I have two datasets, for example, one is the tree.width, having two columns, year (A.. D.1550-2005) and ring width indices; another dataset is the clim.tem, having thirteen columns, year (A. D. 1959-2008) and monthly tem.
I want to calculate the correlation coefficients between the tree ring data and monthly tem. during the common period(A. D. 1959-2005), but I am confused how to index two datasets?
So I have to give a fixed range of common period for the datasets in the for loop, just as following:
cor.std<-matrix(NA,nrow=25,ncol=12)
for(i in 1:15)
{
cor.std[i,1]=cor(mne.ylyns[267:313,2],dq.tmn.ex[1:47,i+1],method=c("pearson"))
cor.std[i,2]=cor(mne.ylys[361:407,2],dq.tmn.ex[1:47,i+1],method=c("pearson"))
cor.std[i, 3]=cor(mne.ylls[311:357,2],dq.tmn.ex[1:47,i+1],method=c("pearson"))
-------------
}
Any help is strongly appreciated,
thank you in advance,
----------------------
Zongshan, Li
2010-01-04
Research Center for Eco-Environmental Sciences,Chinese Academy of Sciences
Shuangqing Road, Haidian street, Beijing, 100085
Tel: 86-10-13699145748
QQ: 1141958023
email: ZongShan_Li at yahoo.com
website: http://www.rcees.ac.cn/