So I'm trying to filter out the date and time for individual fish within my data frame. In the code below line 19 by itself will filter the dataframe to give me the times for that ID within the parameters I set but when I add line 20 everything gets filtered out and the data frame is empty.
I assume I'm linking the lines incorrectly but I'm not sure how else it should be done.
ev4<-ev %>%
filter(ID<46|ID>135) %>%
filter(ID!=166) %>% #Take everything but not 166
filter(d<25) %>%
filter(Receiver=="1315"|
Receiver=="1314"|
Receiver=="1321"|
Receiver=="1404"|
Receiver=="1318"|
Receiver=="1325"|
Receiver=="1313"|
Receiver=="1323"|
Receiver=="1324"|
Receiver=="1320"|
Receiver=="1319"|
Receiver=="1317"|
Receiver=="1327"|
Receiver=="1316") %>%
filter(ID == "1", dt <= as.POSIXct("2020-05-23 03:20:36"), dt >= as.POSIXct("2020-05-07 23:50:12")|
ID=="3",dt <= as.POSIXct("2020-05-03 16:13:00")) %>%
filter() %>%
mutate(sp=case_when(ID<46~"salmon", T~"trout")) %>%
mutate(dt=ymd_hms(dt)) %>%
as_tibble()
For example if my dataframe was like:
I might want to filter the dataframe so it only contained the dates for ID 138 between "2020-04-23 19:26:47" and 2020-04-23 19:26:56. But I would also want to be able to keep the rest of the data frame intact.