I want to calculate the average value for each "Day", but for a fraction of the day (Time = 12-14). This code works for me, but I have to enter every day as a new line of code, which will be hundreds of lines.
It seems that this should be easy to do. I made it easy when the grouping variables are the same, but donβt know how to do it when I donβt want to include all the values ββthroughout the day. Is there a better way to do this?
sapply(sap[sap$Day==165 & sap$Time %in% c(12,12.1,12.2,12.3,12.4,12.5,13,13.1,13.2,13.3,13.4,13.5, 14), ],mean) sapply(sap[sap$Day==166 & sap$Time %in% c(12,12.1,12.2,12.3,12.4,12.5,13,13.1,13.2,13.3,13.4,13.5, 14), ],mean)
Here's what the data looks like:
Day Time StomCond_Trunc 165 12 33.57189926 165 12.1 50.29437636 165 12.2 35.59876214 165 12.3 24.39879768