Oops, I am terribly sorry, I recognized my mistake, as I thought that the factors are ordered in PPress, 1 1 (k times) 1 2 (k times) 1 3 (k times) etc... Of course, "solution" I supplied is then not correct. Thank you for your notice and for a more general solution. Jan ------------------------------------------------- designed for _monospaced_ font ------------------------------------------------- /- Jan Svatos, Sokolovska 855/225 -/ /- Data Analyst, Prague 9 -/ /- Eurotel Praha 190 00 -/ /- jan_svatos at eurotel.cz Czechia -/ ------------------------------------------------- "Dieter Menne" <dieter.menne at menne- <Jan_Svatos at eurotel.cz> biomed.de> 07/31/01 11:36 AM AW: [R] Applying "by" results Jan, I tried again, and I am sorry to say that your result is not correct. I would only work if the data are ordered from the beginning in the same order as they are processed. See below: Press1 is not correct (not easy to see). Press 2 is correct. set.seed(13) PPress<-data.frame(Marker=as.factor(c(rep(1,12),rep(2,12))), Chan=as.factor(rep(1:4,6)), Press=rnorm(24) ) attach(PPress) PPress$Press1<-unlist(by (Press,list(Marker,Chan), function(x) x-min(x))) minp<-unlist(tapply(Press,list(Chan,Marker),min,simplify=F)) imin<-tapply(Press,list(Chan,Marker)) PPress$Press2<-Press-minp[imin] Dieter -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._