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@yahoo.com
website: http://www.rcees.ac.cn/  


      
	[[alternative HTML version deleted]]

