Re: [R] How to join data.frames and vectors of different length, in an inteligent way?

2008-06-10 Thread Hvidberg, Martin
Thanks Chuck With your help I managed to write the code as I wanted it. The result looks like this: dafSamp <- data.frame(cbind(c(1972,1984,1969,1976,1999,1996,1976,1984,1976),c(117,7 3,92,113,80,78,98,106,99))) dafSamp$Ay <- ave(dafSamp$X2, dafSamp$X1, FUN=mean) dafSamp$AA <- dafSamp$X2 * (mean(

[R] How to join data.frames and vectors of different length, in an inteligent way?

2008-06-10 Thread Hvidberg, Martin
* Ay[which(Ay[,1]==dafSamp[,1]),2] / Ag University of Aarhus <http://www.au.dk/en> Danmarks Miljøundersøgelser <http://www.dmu.dk/> Hvidberg, Martin <http://www2.dmu.dk/1_Om_DMU/2_medarbejdere/cv/employee2_NH.asp?PersonID=MHV> Senior Geographer (