I have offset time between UTC and local time at different locations as following (+/-HH:MM):
> x
# [1] "+00:00" "+00:00" "-03:00" "+01:00" "+03:00" "+03:00" "+00:00" "+01:00"
# [9] "+00:00" "+00:00" "+02:00" "+01:00" "+02:00" "-02:00" "+00:00" "+01:00"
How can I convert this to a time interval, then use it to shift Sys.Date() using the numbers above?
Another solution using as.difftime (there is a bit of gymnastics to do because it doesn't recognized signed character input):
x <- c("+00:00","+00:00","-03:00","+01:00","+03:00","+03:00","+00:00","+01:00","+00:00","+00:00","+02:00","+01:00","+02:00","-02:00","+00:00","+01:00")
as.difftime(gsub("[+-]","",x), format ="%H:%M") * ifelse(grepl("^-",x),-1,1)
#Time differences in secs
# [1] 0 0 -10800 3600 10800 10800 0 3600 0 0 7200 3600 7200 -7200 0 3600
#attr(,"tzone")
#[1] ""
So to shift from Sys.time(), it's simply:
Sys.time()+as.difftime(gsub("[+-]","",x),format ="%H:%M") * ifelse(grepl("^-",x),-1,1)
#[1] "2015-07-10 10:36:32 CEST" "2015-07-10 10:36:32 CEST" "2015-07-10 07:36:32 CEST" "2015-07-10 11:36:32 CEST" "2015-07-10 13:36:32 CEST" "2015-07-10 13:36:32 CEST" "2015-07-10 10:36:32 CEST"
#[8] "2015-07-10 11:36:32 CEST" "2015-07-10 10:36:32 CEST" "2015-07-10 10:36:32 CEST" "2015-07-10 12:36:32 CEST" "2015-07-10 11:36:32 CEST" "2015-07-10 12:36:32 CEST" "2015-07-10 08:36:32 CEST"
#[15] "2015-07-10 10:36:32 CEST" "2015-07-10 11:36:32 CEST"
If you had your input as numbers, it would be even more straightforward, since it does recognized signed numeric input:
y <- c(-1,2,3,0,-4,-6.5)
Sys.time() + as.difftime(y, units="hours")
# [1] "2015-07-10 09:39:31 CEST" "2015-07-10 12:39:31 CEST" "2015-07-10 13:39:31 CEST" "2015-07-10 10:39:31 CEST" "2015-07-10 06:39:31 CEST" "2015-07-10 04:09:31 CEST"
Here I have a (clumsy) solution, but it works I think. Waiting for more elegant solutions. Steps are, gsub to strings all punctuations and the + sign. convert them all in numeric, divide by 100 in order to have, example -200 as -2, and them pass them all as arguments of the hours function.
library(lubridate)
x1 <- gsub("[:punct:]|\\+", "", x)
x1 <- as.numeric(as.character(x1))
x1 <- x1 / 100
Sys.Date() + hours(x1)
[1] "2015-07-09 00:00:00 UTC" "2015-07-09 00:00:00 UTC"
[3] "2015-07-08 21:00:00 UTC" "2015-07-09 01:00:00 UTC"
[5] "2015-07-09 03:00:00 UTC" "2015-07-09 03:00:00 UTC"
[7] "2015-07-09 00:00:00 UTC" "2015-07-09 01:00:00 UTC"
[9] "2015-07-09 00:00:00 UTC" "2015-07-09 00:00:00 UTC"
[11] "2015-07-09 02:00:00 UTC" "2015-07-09 01:00:00 UTC"
[13] "2015-07-09 02:00:00 UTC" "2015-07-08 22:00:00 UTC"
[15] "2015-07-09 00:00:00 UTC" "2015-07-09 01:00:00 UTC"
data I have used:
x <- c("+00:00", "+00:00", "-03:00", "+01:00", "+03:00", "+03:00", "+00:00", "+01:00",
"+00:00", "+00:00", "+02:00", "+01:00", "+02:00", "-02:00", "+00:00", "+01:00")
Edit: a solution for minutes too
Here the data used is the vector y that contains minutes too.
y <- c("+03:30", "+02:45", "-03:50", "-05:00")
y1 <- unlist(strsplit(y, "[:punct:]"))
y1 <- gsub("\\+", "", y1)
y1 <- as.numeric(as.character(y1))
MinuteS <- y1[1:length(y1) %% 2 == 0]
HourS <- y1[1:length(y1) %% 2 == 1]
Sys.Date() + minutes(MinuteS) + hours(HourS)
[1] "2015-07-09 03:30:00 UTC"
[2] "2015-07-09 02:45:00 UTC"
[3] "2015-07-08 21:50:00 UTC"
[4] "2015-07-08 19:00:00 UTC"
Related
I have convert my date from chr to POSIXCT using formula below.
crime2$Date = parse_date_time(crime2$Date, orders = c('dmy_HM'),tz="UTC")
so my date actually now in this format.
> head(crime2$Date, 10)
[1] "2015-03-18 19:44:00 UTC" "2015-03-18 22:45:00 UTC"
[3] "2015-03-18 22:30:00 UTC" "2015-03-18 22:00:00 UTC"
[5] "2015-03-18 23:00:00 UTC" "2015-03-18 21:35:00 UTC"
[7] "2015-03-18 22:50:00 UTC" "2015-03-18 23:40:00 UTC"
[9] "2015-03-18 23:30:00 UTC" "2015-03-18 22:45:00 UTC"
However, if i want to remove the time and keep the date only, what can i do about this?
Example, they will look like this
" 2015-03-18 " "2015-03-18 "
In my dataframe, I have dates of the form
YYYY-MM-DD
YYYY.MM.DD
YYYY-MM-DD HH:MM
I want to standardise it into the form:
YYYY-MM-DD
in R.
I've tried the parse_date_time() function in R, but not all the columns are parsed. Why is that so? Any help would be appreciated :-)
Edit
An example for the usage of
parse_date_time(emails$mail_sent_date)
is this
[1] NA "2010-04-17 UTC" "2012-01-26 UTC" "2014-11-15 UTC" "2014-07-17 UTC" "2010-02-22 UTC" "2010-07-17 UTC" "2012-10-27 UTC" "2014-01-18 UTC"
[10] "2010-01-11 UTC" NA "2010-11-28 UTC" "2012-09-24 UTC" "2014-05-30 UTC" "2014-05-30 UTC" "2010-07-31 UTC" "2007-07-28 UTC" NA
[19] "2014-08-29 UTC" "2015-06-05 UTC" "2008-11-03 UTC" "2018-03-18 UTC" "2019-01-12 UTC" "2011-07-23 UTC" NA "2007-11-19 UTC" "2019-04-07 UTC"
[28] "2010-11-28 UTC" "2019-11-22 UTC" "2019-03-28 UTC" "2013-06-22 UTC" "2013-12-08 UTC" "2012-06-08 UTC" "2011-12-09 UTC" "2017-10-23 UTC" "2017-03-26 UTC"
[37] "2019-01-31 UTC" "2020-03-14 UTC" "2014-05-30 UTC" "2011-12-31 UTC" "2015-05-14 UTC" "2010-03-27 UTC" "2014-12-08 UTC" "2015-05-24 UTC" "2014-11-15 UTC"
[46] NA "2018-05-26 UTC" "2019-02-28 UTC" NA "2015-06-11 UTC" "2012-06-09 UTC" "2013-06-16 UTC" NA "2014-07-12 UTC"
[55] "2012-09-20 UTC" "2010-05-22 UTC" "2019-11-07 UTC" "2011-03-07 UTC" "2007-10-05 UTC" "2018-03-17 UTC" "2007-06-22 UTC" "2007-02-01 UTC" "2020-03-29 UTC"
[64] "2010-03-21 UTC" "2019-02-28 UTC" NA "2008-03-17 UTC" "2013-03-14 UTC" "2014-05-12 UTC" "2015-12-19 UTC" "2010-04-05 UTC" NA
[73] "2008-02-07 UTC" "2007-08-12 UTC" "2011-12-02 UTC" "2014-02-02 UTC" "2011-07-25 UTC" "2014-06-12 UTC" NA NA "2013-10-06 UTC"
[82] "2019-05-18 UTC" "2011-12-19 UTC" NA "2012-03-18 UTC" "2013-07-22 UTC" "2017-01-21 UTC" "2013-09-26 UTC" "2019-04-18 UTC" "2012-10-01 UTC"
[91] "2018-09-01 UTC" "2019-11-22 UTC" "2013-07-05 UTC" "2013-07-22 UTC" "2008-10-11 UTC" "2018-04-29 UTC" NA "2019-06-24 UTC" "2018-04-19 UTC"
[100] "2015-08-21 UTC" NA NA "2015-04-09 UTC" "2012-02-11 UTC" "2011-11-13 UTC" "2013-04-11 UTC" "2007-10-07 UTC" "2007-10-08 UTC"
[109] "2012-01-14 UTC" "2012-06-02 UTC" "2011-07-04 UTC" "2019-05-17 UTC" "2012-09-09 UTC" NA "2018-09-29 UTC" "2015-06-04 UTC" "2014-01-13 UTC"
[118] "2014-01-13 UTC" "2012-09-24 UTC" "2018-05-28 UTC" "2018-07-21 UTC" "2010-04-26 UTC" "2011-02-20 UTC" "2013-06-21 UTC" "2008-12-14 UTC" "2011-04-25 UTC"
[127] "2014-07-31 UTC" "2015-06-08 UTC" "2015-10-25 UTC" "2019-06-29 UTC" "2011-02-21 UTC" "2017-01-09 UTC" NA "2015-06-21 UTC" "2014-07-28 UTC"
[136] "2013-11-04 UTC" "2014-07-24 UTC" NA "2019-09-13 UTC" "2007-06-09 UTC" "2014-12-13 UTC" "2015-10-16 UTC" "2010-06-19 UTC" "2015-05-14 UTC"
[145] "2011-07-29 UTC" "2007-10-01 UTC" NA NA "2010-09-25 UTC" "2010-04-15 UTC" "2020-03-05 UTC" "2017-06-30 UTC" NA
[154] "2019-06-10 UTC" "2018-10-04 UTC" "2015-05-11 UTC" "2010-05-22 UTC" "2014-07-26 UTC" "2015-01-25 UTC" "2015-07-04 UTC" "2015-07-04 UTC" "2014-07-17 UTC"
[163] "2010-09-18 UTC" "2007-01-08 UTC" "2019-10-21 UTC" "2014-06-30 UTC" "2008-08-01 UTC" NA "2010-08-13 UTC" NA NA
[172] "2012-11-24 UTC" "2014-11-20 UTC" "2018-05-14 UTC" "2015-10-05 UTC" "2020-01-26 UTC" "2018-04-21 UTC" "2011-07-04 UTC" "2015-02-22 UTC" "2015-02-22 UTC"
[181] "2008-10-11 UTC" "2017-01-05 UTC" "2011-05-21 UTC" NA "2015-09-27 UTC" "2011-08-28 UTC" "2019-03-09 UTC" "2018-11-29 UTC" "2014-07-11 UTC"
[190] "2013-06-14 UTC" "2018-06-04 UTC" "2014-11-03 UTC" "2019-03-01 UTC" "2007-10-12 UTC" "2018-01-06 UTC" NA "2010-11-28 UTC" "2017-10-23 UTC"
[199] "2014-03-23 UTC" "2018-11-11 UTC" "2019-05-18 UTC" "2014-10-02 UTC" NA NA "2011-07-31 UTC" "2010-07-16 UTC" "2015-04-09 UTC"
[208] "2015-10-01 UTC" "2015-10-09 UTC" "2011-04-01 UTC" "2018-11-11 UTC" "2018-11-11 UTC" "2011-08-28 UTC" "2018-07-21 UTC" NA "2011-02-21 UTC"
[217] "2018-03-17 UTC" NA "2014-05-11 UTC" "2012-03-23 UTC" "2014-05-25 UTC" "2014-03-23 UTC" "2013-01-20 UTC" NA "2014-07-11 UTC"
[226] "2014-09-08 UTC" "2013-05-24 UTC" NA "2010-07-17 UTC" NA "2019-01-01 UTC" NA "2013-06-15 UTC" "2019-01-19 UTC"
[235] "2020-02-02 UTC" "2013-03-14 UTC" "2012-08-04 UTC" "2015-02-13 UTC" "2010-06-18 UTC" NA "2013-10-20 UTC" "2015-12-17 UTC" "2017-09-01 UTC"
[244] "2013-03-28 UTC" "2010-04-01 UTC" "2017-07-24 UTC" "2007-09-30 UTC" "2017-05-27 UTC" NA "2006-11-17 UTC" "2007-11-18 UTC" "2019-12-01 UTC"
[253] "2015-10-12 UTC" "2015-03-27 UTC" "2017-12-02 UTC" "2018-09-03 UTC" "2018-03-04 UTC" "2015-03-14 UTC" NA "2010-01-25 UTC" "2008-07-04 UTC"
[262] "2015-04-29 UTC" "2013-04-05 UTC" NA "2007-11-02 UTC" "2010-06-13 UTC" "2019-02-16 UTC" "2015-04-09 UTC" "2013-07-27 UTC" NA
[271] "2018-08-25 UTC" "2019-06-14 UTC"
Warning message:
39 failed to parse.
A similar warning message returned when I used ymd()
1) Assuming that the formats are precisely the ones shown in the question (if not please fix the question) then this uses only base R. This makes use of the fact that as.Date will ignore junk at the end.
x <- c("2000-10-01", "2000.10.01", "2000-10-01 03:04")
as.Date(chartr(".", "-", x))
## [1] "2000-10-01" "2000-10-01" "2000-10-01"
2) Another approach is the anytime package:
library(anytime)
anydate(x)
## [1] "2000-10-01" "2000-10-01" "2000-10-01"
Use lubridate package and ymd function
library(lubridate)
ymd(column_of_your_dataframe)
I have some odd looking variables which I need to convert into a Date class:
dates <- c(" 26JUL2018:23:59:59", " 02APR2018:23:59:59", " 02MAY2018:23:59:59",
" 22APR2018:23:59:59", " 27MAY2018:23:59:59", " 04MAR2018:23:59:59",
" 10APR2018:23:59:59", NA, " 04SEP2018:23:59:59", " 21APR2017:23:59:59"
)
> dates
[1] " 26JUL2018:23:59:59" " 02APR2018:23:59:59" " 02MAY2018:23:59:59"
[4] " 22APR2018:23:59:59" " 27MAY2018:23:59:59" " 04MAR2018:23:59:59"
[7] " 10APR2018:23:59:59" NA " 04SEP2018:23:59:59"
[10] " 21APR2017:23:59:59"
I tried the following which just produces NAs:
as.POSIXct(dates, format=" %d%m%Y:%H:%M:%S")
as.POSIXct(dates, format=" %d%mm%Y:%H:%M:%S")
I also tried removing the spaces using gsub, then using format="%d%m%Y:%H:%M:%S" and format="%d%mm%Y:%H:%M:%S" but neither worked.
What is the correct way to format this vector into class Date?
You can use %b as Abbreviated month name in the current locale on this platform. (Also matches full name on input: in some locales there are no abbreviations of names.)
as.POSIXct(dates, format="%d%b%Y:%H:%M:%S")
# [1] "2018-07-26 23:59:59 CEST" "2018-04-02 23:59:59 CEST"
# [3] "2018-05-02 23:59:59 CEST" "2018-04-22 23:59:59 CEST"
# [5] "2018-05-27 23:59:59 CEST" "2018-03-04 23:59:59 CET"
# [7] "2018-04-10 23:59:59 CEST" NA
# [9] "2018-09-04 23:59:59 CEST" "2017-04-21 23:59:59 CEST"
A lubridate one-liner using dmy_hms (day-month-year/hour-minute-second)
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#>
#> date, intersect, setdiff, union
dmy_hms(dates)
#> [1] "2018-07-26 23:59:59 UTC" "2018-04-02 23:59:59 UTC"
#> [3] "2018-05-02 23:59:59 UTC" "2018-04-22 23:59:59 UTC"
#> [5] "2018-05-27 23:59:59 UTC" "2018-03-04 23:59:59 UTC"
#> [7] "2018-04-10 23:59:59 UTC" NA
#> [9] "2018-09-04 23:59:59 UTC" "2017-04-21 23:59:59 UTC"
If you want a different timezone, use the tz argument.
In 2013, the switch from Central European Time (CET) to Central European Summer Time (CEST) took place on Sunday 2013-03-31. Clocks are advanced by one hour from 2am to 3pm, so basically there is no 2am.
start <- strptime("2013-03-31 01:00:00", format="%F %T", tz="CET")
times <- start + (0:5) * 60*15
times
[1] "2013-03-31 01:00:00 CET" "2013-03-31 01:15:00 CET"
[3] "2013-03-31 01:30:00 CET" "2013-03-31 01:45:00 CET"
[5] "2013-03-31 03:00:00 CEST" "2013-03-31 03:15:00 CEST"
Rounding the vector times to hours gives NAs. Even for times before 01:30, which aren't affected by the transition at all.
library(lubridate)
round_date(times, unit = "hour")
[1] "2013-03-31 01:00:00 CET" NA
[3] NA NA
[5] NA "2013-03-31 03:00:00 CEST"
This seems to be a bug, or am I missing something? I am running:
sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=German_Austria.1252 LC_CTYPE=German_Austria.1252
[3] LC_MONETARY=German_Austria.1252 LC_NUMERIC=C
[5] LC_TIME=German_Austria.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lubridate_1.3.3
loaded via a namespace (and not attached):
[1] digest_0.6.4 memoise_0.2.1 plyr_1.8.1 Rcpp_0.11.2 stringr_0.6.2
It looks like the culprit is ceiling_date which is called by round_date:
ceiling_date(times,"hour")
[1] "2013-03-31 01:00:00 CET" NA
[3] NA NA
[5] NA "2013-03-31 04:00:00 CEST"
Looking at the code it works by adding 1 to the hour, thereby creating a non-existant time. It is definitely a bug.
base::round has support for times to do what you want though:
round(times,"hour")
[1] "2013-03-31 01:00:00 CET" "2013-03-31 01:00:00 CET"
[3] "2013-03-31 03:00:00 CEST" "2013-03-31 03:00:00 CEST"
[5] "2013-03-31 03:00:00 CEST" "2013-03-31 03:00:00 CEST"
It's an edge case and you could consider the behavior a bug. round_date uses ceiling_date and there this happens:
y <- floor_date(times - eseconds(1), "hour")
#[1] "2013-03-31 00:00:00 CET" "2013-03-31 01:00:00 CET" "2013-03-31 01:00:00 CET" "2013-03-31 01:00:00 CET" "2013-03-31 01:00:00 CET" "2013-03-31 03:00:00 CEST"
hour(y) <- hour(y) + 1
#[1] "2013-03-31 01:00:00 CET" NA NA NA NA "2013-03-31 04:00:00 CEST"
As you see it tries to increment 2013-03-31 01:00:00 CET by one hour and doesn't deal correctly with the time zones.
The root issue is probably in the "hour<-" POSIXct S4 method.
This has been fixed in master:
> times <- ymd_hms("2013-03-31 01:00:00 CET", "2013-03-31 01:15:00 CEST",
+ "2013-03-31 01:30:00 CEST", "2013-03-31 01:45:00 CEST",
+ "2013-03-31 03:00:00 CEST", "2013-03-31 03:15:00 CEST",
+ tz = "Europe/Amsterdam")
> round_date(times, unit = "hour")
[1] "2013-03-31 01:00:00 CET" "2013-03-31 01:00:00 CET" "2013-03-31 03:00:00 CEST"
[4] "2013-03-31 03:00:00 CEST" "2013-03-31 03:00:00 CEST" "2013-03-31 03:00:00 CEST"
> ceiling_date(times, unit = "hour")
[1] "2013-03-31 01:00:00 CET" "2013-03-31 03:00:00 CEST" "2013-03-31 03:00:00 CEST"
[4] "2013-03-31 03:00:00 CEST" "2013-03-31 03:00:00 CEST" "2013-03-31 04:00:00 CEST"
Melting the dataframe t.wide changes how the column "time" (class POSIXct) is printed.
t.wide <- data.frame(product=letters[1:5],
result=c(2, 4, 0, 0, 1),
t1=as.POSIXct("2014-05-26") + seq(0, 10800, length.out=5),
t2=as.POSIXct("2014-05-27") + seq(0, 10800, length.out=5),
t3=as.POSIXct("2014-05-28") + seq(0, 10800, length.out=5))
library(reshape2)
t.long <- melt(t.wide, measure.vars=c("t1", "t2", "t3"), value.name="time")
t.long$time
[1] 1401055200 1401057900 1401060600 1401063300 1401066000 1401141600 1401144300
[8] 1401147000 1401149700 1401152400 1401228000 1401230700 1401233400 1401236100
[15] 1401238800
attr(,"class")
[1] "POSIXct" "POSIXt"
Strangely, if print() is called explicitly, the object is printed as expected (timestamps, not their numeric representation).
print(t.long$time)
[1] "2014-05-26 00:00:00 CEST" "2014-05-26 00:45:00 CEST" "2014-05-26 01:30:00 CEST"
[4] "2014-05-26 02:15:00 CEST" "2014-05-26 03:00:00 CEST" "2014-05-27 00:00:00 CEST"
[7] "2014-05-27 00:45:00 CEST" "2014-05-27 01:30:00 CEST" "2014-05-27 02:15:00 CEST"
[10] "2014-05-27 03:00:00 CEST" "2014-05-28 00:00:00 CEST" "2014-05-28 00:45:00 CEST"
[13] "2014-05-28 01:30:00 CEST" "2014-05-28 02:15:00 CEST" "2014-05-28 03:00:00 CEST"
Setting the attributes to the same value as before magically changes how the object is printed.
attributes(t.long$time) <- attributes(t.long$time)
t.long$time
[1] "2014-05-26 00:00:00 CEST" "2014-05-26 00:45:00 CEST" "2014-05-26 01:30:00 CEST"
[4] "2014-05-26 02:15:00 CEST" "2014-05-26 03:00:00 CEST" "2014-05-27 00:00:00 CEST"
[7] "2014-05-27 00:45:00 CEST" "2014-05-27 01:30:00 CEST" "2014-05-27 02:15:00 CEST"
[10] "2014-05-27 03:00:00 CEST" "2014-05-28 00:00:00 CEST" "2014-05-28 00:45:00 CEST"
[13] "2014-05-28 01:30:00 CEST" "2014-05-28 02:15:00 CEST" "2014-05-28 03:00:00 CEST"
Can anyone explain this behavior?
UPDATE:
I opened this as Issue #50 on the git repo hadley/reshape2.
UPDATE: FIXED
This issue has been fixed in the development version of reshape2.
Thanks #kevin-ushey!
I believe the reason is because after the reshaping for whatever reason R does not think that t.long$time has attributes. For some reason the OBJECT flag (which indicates the vector has attributes) in the SEXP header for your vector is not being set. When you copy the attributes back to it, the OBJECT flag gets set and the correct print method is dispatched...
# No "OBJ" in SEXP header (the '[NAM(2),ATT]' part below)
.Internal(inspect( t.long$time ) )
##10359e548 14 REALSXP g0c6 [NAM(2),ATT] (len=15, tl=0) 1.40106e+09,...
# Now we have "OBJ" in the SEXP header indicating attributes
# So the print method for POSIXct get dispatched...
attributes(t.long$time) <- attributes(t.long$time)
.Internal(inspect( t.long$time ) )
##1118d7f50 14 REALSXP g0c6 [OBJ,NAM(2),ATT] (len=15, tl=0) 1.40106e+09,...
From the R Internals document...
The actual autoprinting is done by PrintValueEnv in file print.c. If the object to be printed has the S4 bit set and S4 methods dispatch is on, show is called to print the object. Otherwise, if the object bit is set (so the object has a "class" attribute), print is called to dispatch methods: for objects without a class the internal code of print.default is called.
Check the difference between..
print.default(t.long$time)
# [1] 1401058800 1401061500 1401064200 1401066900 1401069600 1401145200 1401147900 1401150600 1401153300 1401156000 1401231600 1401234300
#[13] 1401237000 1401239700 1401242400
#attr(,"class")
#[1] "POSIXct" "POSIXt"
print.POSIXct(t.long$time)
# [1] "2014-05-26 00:00:00 BST" "2014-05-26 00:45:00 BST" "2014-05-26 01:30:00 BST" "2014-05-26 02:15:00 BST" "2014-05-26 03:00:00 BST"
# [6] "2014-05-27 00:00:00 BST" "2014-05-27 00:45:00 BST" "2014-05-27 01:30:00 BST" "2014-05-27 02:15:00 BST" "2014-05-27 03:00:00 BST"
#[11] "2014-05-28 00:00:00 BST" "2014-05-28 00:45:00 BST" "2014-05-28 01:30:00 BST" "2014-05-28 02:15:00 BST" "2014-05-28 03:00:00 BST"
Now I can only speculate, but perhaps this is due to some internal code in reshape2 and is related to this warning..
One thing to watch is that if you copy attributes from one object to another you may (un)set the "class" attribute and so need to copy the object and S4 bits as well. There is a macro/function DUPLICATE_ATTRIB to automate this.