Skip to content
  • I found another way to do this, if you are interested in having S equals 0 for time periods where the fish were not heard at all and considered absent. You can add in complete() from tidyr and remove filter(!S < 10) when you create S. When you use left join() you'll have the variable t which will end up with many NA values which can be replaced to 0 using the following ri_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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment