I have a data frame that looks as follows (8 columns – the myPOSIX column is in ‘y-m-d h:s’ format)
head(new)
Date.and.Time..UTC. Receiver Transmitter Latitude Longitude ndiffs29912 flag
1 07/10/2010 15:53 VR2W-107619 A69-1303-29912 48.56225 -53.89144 NA FALSE 2010-10-07
2 07/10/2010 15:56 VR2W-107619 A69-1303-29912 48.56225 -53.89144 180 FALSE 2010-10-07
3 07/10/2010 16:00 VR2W-107619 A69-1303-29912 48.56225 -53.89144 240 FALSE 2010-10-07
4 07/10/2010 16:24 VR2W-107619 A69-1303-29912 48.56225 -53.89144 1440 FALSE 2010-10-07
5 07/10/2010 16:45 VR2W-104556 A69-1303-29912 48.56460 -53.88956 1260 FALSE 2010-10-07
6 07/10/2010 16:47 VR2W-107619 A69-1303-29912 48.56225 -53.89144 120 FALSE 2010-10-07
myPOSIX
15:53:00
15:56:00
16:00:00
16:24:00
16:45:00
16:47:00
My goal is to bin the detections into hour time bins. Then, for each time bin, I would like to calculate weighted means for latitude and longitude, using the number of detections per receiver as the weighting measure (ie the frequency of the different receiver names in each bin).
Any insight would be greatly appreciated – I’ve been trying to work out a code using the zoo and xts package for aggregating hourly detections, but have not succeeded.
1 Answer