Skip to content
Back to formatted view

Raw Message

Message-ID: <4D3054E4.60303@nic.fi>
Date: 2011-01-14T13:51:32Z
From: K. Elo
Subject: test
In-Reply-To: <1294996658118-3217329.post@n4.nabble.com>

Dear Romezo,

a solution maybe not that elegant and effective, but seems to work:

test_calculate<-function() {
   tarrow<-1
   TARGET<-data.frame("Thesis"=0, "Day"=0,"A"=0,"B"=0,"C"=0)
   for (i in c(unique(my.data$Thesis))) {
     for (j in c(unique(my.data$Day[ my.data$Thesis==i ]))) {
       TEMPDF<-subset(my.data, Thesis==i & Day==j)
       for (k in c(1:(nrow(TEMPDF)-1))) {
         for (l in c((k+1):nrow(TEMPDF))) {
           TARGET[tarrow,]<-cbind(i,j,(TEMPDF[k,3]-TEMPDF[l,3]), 
(TEMPDF[k,4]-TEMPDF[l,4]), (TEMPDF[k,5]-TEMPDF[l,5]))
           tarrow<-tarrow+1
         }
       }
     }
   }
   print(TARGET)
}

(Please note: my.data is your original data frame)

Kind regards,
Kimmo