First off, I've found 2 other similar questions on stack overflow, but I still can't figure out how to solve this particular question...
Intially, I wanted to create a new column in my data frame that contained the the date each bird was tracked, but with the time of 21:30.
For example, I wanted to go from this...
BirdID latitude longitude Date
15K12 492719.9 5634805 2015-06-23 18:25:00
15K12 492491.5 5635018 2015-06-23 18:27:00
15K70 455979.1 5653581 2015-06-24 19:54:00
15K70 456040.9 5653668 2015-06-24 19:59:00
To this....
BirdID latitude longitude Date Night
15K12 492719.9 5634805 2015-06-23 04:25:00 2015-06-23 21:30:00
15K12 492491.5 5635018 2015-06-23 04:27:00 2015-06-23 21:30:00
15K70 455979.1 6535815 2015-06-24 03:54:00 2015-06-24 21:30:00
15K70 456040.9 5653668 2015-06-24 03:59:00 2015-06-24 21:30:00
To accomplish this, I used this code....
df <- df %>%
group_by(BirdID) %>%
mutate(night=as.POSIXct(date(min(Date)) + days(0) + hours(21) +
minutes(30),tz="Canada/Pacific"))
However, now I want use slightly different times for some of the individuals. eg, for BirdID= 15K12, 15K70, 15K30 I would like the time to be 21:30 but for BirdID= 14K22, 14K50, 14K62 I would like the time to be 21:20
How do I incorporate this condition into my code?