I would like to write a cleaner way to do the following:
I have data.frame P (5000rows x 4cols) and would like to find the median values ββin columns 2,3 and 4 when the timestamp in column 1 falls within the given range defined by the TimeStamp vector (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")
eg.
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