-
I found another way to do this, if you are interested in having
S
equals0
for time periods where the fish were not heard at all and considered absent. You can add incomplete()
fromtidyr
and removefilter(!S < 10)
when you createS
. When you useleft join()
you'll have the variablet
which will end up with manyNA
values which can be replaced to0
using the followingri_daily[is.na(ri_daily)] <- 0
.S <- df %>% group_by(animal_id, glatos_array, station_no, station, deploy_lat, deploy_long, season_year, time_bin, season_length) %>% summarise(S = n()) %>% ungroup %>% # minumum amount of dets needed to determine if fish was resident # filter(!S < 10) %>% complete(animal_id, nesting( glatos_array, station_no, station, deploy_lat, deploy_long, season_year, time_bin, season_length ), fill = list(S = 0) ) arrange(animal_id, time_bin) S
Edited by Benjamin Hlina
Please register or sign in to comment