79254447

Date: 2024-12-05 11:25:04
Score: 2
Natty:
Report link

I assumed that id is the name of the data.frame you provided at the beginning of the question (correct me if otherwise). Could something like this work maybe?

result_earliest_adjusted <- id %>% 
  mutate(DATE_TIME = as.POSIXct(paste(DATE, TIME), format='%Y-%m-%d %H:%M:%S')) %>%
  group_by(MANUAL.ID, id, DATE.12) %>%  # group by species, id, and sampling night 
  arrange(DATE_TIME, .by_group = T) %>% # sort by occurrence
  filter(row_number()==1) %>%           # take the first for each group
  rename(Earliest_datetime = DATE_TIME)

result_earliest_adjusted

# A tibble: 1 × 7
# Groups:   MANUAL.ID, id, DATE.12 [1]
  DATE       MANUAL.ID TIME      HOUR DATE.12    id    Earliest_datetime  
  <fct>      <fct>     <fct>    <int> <fct>      <chr> <dttm>             
1 2024-08-05 EPTSER    23:55:56    23 2024-08-05 id_1  2024-08-05 23:55:56
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: Luigi