Yes, the number of seconds since the origin 1970-01-01 00:00:00. Just
redefine value as a POSIXct object from that origin:
melt.df$value <- as.POSIXct(melt.df$value, origin = '1970-01-01 00:00:00')
str(melt.df) # verify that it is indeed POSIXct
If you're wondering why value is returning an integer from melt()
rather than a POSIXct object,
> storage.mode(df$start) # ditto for df$end
[1] "integer"
The POSIXct class stores date/time values as the number of seconds
since January 1, 1970 (at 00:00:00). (Spector 2008, 'Data Manipulation
in R', the last sentence on p. 60 that continues onto the following
page.) I think this is a feature of melt() rather than a bug, but you
could always make a feature request :)
OTOH, if you use the reshape() function in base R, it will return the
values as POSIXct:
dfrshp <- reshape(df, idvar = 'id', varying = c('start', 'end'),
v.names = 'value', direction = 'long')
str(dfrshp)
BTW, questions pertaining to plyr and reshape(2) are more appropriate
for the manipulator listserve; go to
http://had.co.nz/reshape/ to
subscribe to that list.
Dennis
>
> Thanks,
> Alastair
>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
>
https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email
ggp...@googlegroups.com
> To unsubscribe: email
ggplot2+u...@googlegroups.com
> More options:
http://groups.google.com/group/ggplot2