I’m still trying to better understand how mlply works. Here is a simplified version of my dataset:
days <- list(c(as.POSIXct("2010-08-29 00:00:00 EDT"), as.POSIXct("2010-08-30 00:00:00 EDT")))
day2 <- list(c(as.POSIXct("2010-07-22 00:00:00 EDT"), as.POSIXct("2010-07-23 00:00:00 EDT"), as.POSIXct("2010-07-24 00:00:00 EDT")))
days <- append(day2, days)
arrivals <- data.frame(date=as.POSIXct("2010-08-29 21:00:00 EDT"), size=72)
arrivals <- rbind(arrivals, c("2010-07-22 17:30:00 EDT",84))
using mapply with pmax to pick the maximum between days and arrivals, I get the following:
starting <- mapply(function(x,y){pmax(x,y)},days,arrivals$date)
starting[[1]]
"2010-08-29 21:00:00 EDT" "2010-08-29 21:00:00 EDT" "2010-08-29 21:00:00 EDT"
I’m sure the next version using mlply is not the equivalent and is obviously my error but, I’m not quite sure why the output differs.
starts <- mlply( cbind(arrivals$date,days), function(date,days){pmax(date,days)})
as.POSIXct(starts[[1]], origin='1970-1-1')
[1] "2010-08-30 02:00:00 EDT" "2010-08-30 02:00:00 EDT" "2010-08-30 02:00:00 EDT"
Ideally, I’m looking how to rewrite the mapply statement using mlply.
Thanks in advance,
–JT
Compare
POSIX references to UTC/GMT. You appear to be 5 hours ahead in your example. This is an output issue internally they appear to be the same times. Further comment is difficult. It would depend on what OS you are running. It could be affected by your locale setings etc.
Also as.POSIXct gives an unexpected timezone suggests there maybe an issue with
as.POSIXct.datebut Im not sure if this is still an issue.