I have a dataset of dives (captured by time-depth recorder attached to a diving bird), which consists of among many other variables, dive depths, dive duration, and post dive duration (time spent resting before starting another dive). What I have been trying to do (unsuccessfully) is identify dive bouts, which are multiple dives that occur within a set period of time, with a certain amount of time between. As an example, 5 sequential dives would be considered a diving bout if the first 4 have a post dive duration of <300s, and the 5th has one greater than >300s. The 6th dive would be considered the start of a new bout, and the end would be the next dive that has a post dive duration >300s. I'm sure there is a simple solution to identify patterns like this, but I don't really know how to approach this in R. I would also like to have each bout numbered and placed in a new column labeled "BoutID" if possible. Can anyone make any suggestions? See example of what the output I am looking for.
Thanks!
divedepth <- c(10, 11, 13, 12, 15, 25, 30, 5, 7, 3, 10)
divetime <- c(60, 50, 45, 45, 30, 50, 25, 10, 50, 30, 33)
postdivetime <- c(5, 10, 3, 5, 301, 1, 4, 7, 305, 10, 301)
boutID <- c(1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3)
dives <- data.frame(divedepth, divetime, postdivetime, boutID)
dives
divedepth divetime postdivetime boutID
1 10 60 5 1
2 11 50 10 1
3 13 45 3 1
4 12 45 5 1
5 15 30 301 1
6 25 50 1 2
7 30 25 4 2
8 5 10 7 2
9 7 50 305 2
10 3 30 10 3
11 10 33 301 3
Aucun commentaire:
Enregistrer un commentaire