I would like to know if it is possible using dplyr to count the number of "visits". A visit is defined by every time the elapsed time is more than 30 or when the species change. 

I tried grouping them by species 

```
visit <- rawdata %>%
  group_by(Species)%>%
  mutate(VisitNo = cumsum(Elapsed >= 30) 

```

But this makes that every species starts again at 0

```
Species    Elapsed VisitNo
aardvark     5 
aardvark     10
aardvark     2 
aardvark     30 
aardvark     4 
aardvark     30 
aardvark     10
Jackal       5
Jackal       30
Impala       5
Impala       30`

```

expected output

```
Species    Elapsed VisitNo
aardvark     5          1
aardvark     10         1
aardvark     2          1
aardvark     30         2
aardvark     4          2 
aardvark     30         3
aardvark     10         3
Jackal       5          4
Jackal       30         5
Impala       5          5
Impala       30         6

```

Thanks for the help.