[R] test
K. Elo
maillists at nic.fi
Fri Jan 14 14:51:32 CET 2011
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
More information about the R-help
mailing list