Hi all,

This is a really basic question but I can't figure it out.

I am trying to write a piece of code that will  use two datasets, z and m..
This code is meant to assign the mean of selected values in dataset m to a new column z$c in datset z but the rows and columns of the two data sets differ.

I managed to write this down but think I am missing something standard but basic,I will really appreciate if someone could point out where I' am going wrong or help me out with a piece of code for this.Google did not help me even and the R manuals gave me hints.

"The shoulders will never grow beyond the head".

for (k in 1:nrow(z))
+ for (g in 1:nrow(m))
+ for (l in 1:3)
+ for (j in 15:43){
+ z$ccs[k]<-mean(m[m$soi[g]==l&m$week[g]==j,]$CCS,na.rm=TRUE)}









      
	[[alternative HTML version deleted]]


