I'd like to be able to write a cleaner way of doing the following:
I have a data.frame P (5000rows x 4cols) and would like to find the median values in columns 2,3 and 4 when the time-stamp in column 1 falls into a set range determined by a vector TimeStamp (in seconds).
dput(TimeStamp)
c(18, 138, 438, 678, 798, 1278, 1578, 1878, 2178)
dput(head(P))
structure(list(Time = c(0, 5, 100, 200, 500, 1200), SkinTemp = c(27.781,
27.78, 27.779, 27.779, 27.778, 27.777), HeartRate = c(70, 70,
70, 70, 70, 70), RespirationRate = c(10, 10, 10, 10, 10, 10)), .Names = c("Time",
"SkinTemp", "HeartRate", "RespirationRate"), row.names = c(NA,
6L), class = "data.frame")
e.g.
for x<i<y in P[,1]
find median of all values in P[,2], P[,3] and P[,4]
Put median values into a new matrix with headers SkinTemp, HeartRate and RespirationRate
end