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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to