I'm working with data from a municipal fire department. I'm trying to identify the arrival time of the first emergency vehicle for every 9-1-1 call, some calls only had one emergency vehicle, while others had more than one. Each entry is identified by a call number (CallNum), there's a dispatch time (Dispatched), an arrival time(Arrived), and a cleared time(Cleared), there are other columns, but that doesn't matter for this task. The times were entered in military style. I was able to compute this quite successfully.
Woburn2 <- WoburnFire %>% group_by(CallNum) %>%
summarise(FirstVehicle = min(Arrived), rm.na= TRUE)
This should be the end of it, but ran into a few issues. First, when there are multiple emergency vehicles with the same arrival time, I get a blank value in the FirstVehicle column. Second, if there's a blank value among the arrival times, then the blank value will go into the FirstVehicle column.
So how can I create an if statement in the summarize function, that if the min(Arrived) value is NA return the second value, and if the Arrived values are all equal, return the Arrived time.