Working with Dates and Times in R
Charlotte Wickham
Instructor
HH:MM:SS
:POSIXlt - list with named componentsPOSIXct - seconds since 1970-01-01 00:00:00POSIXct will go in a data frameas.POSIXct() turns a string into a POSIXct object
x <- as.POSIXct("1970-01-01 00:01:00")
str(x)
POSIXct[1:1], format: "1970-01-01 00:01:00"
"2013-02-27T18:00:00" - 6pm local time
"2013-02-27T18:00:00Z" - 6pm UTC
"2013-02-27T18:00:00-08:00" - 6pm in Oregon
as.POSIXct("2013-02-27T18:00:00Z")
"2013-02-27 PST"
as.POSIXct("2013-02-27T18:00:00Z", tz = "UTC")
"2013-02-27 UTC"
Once a POSIXct object, datetimes can be:
Compared
Subtracted
Plotted
Working with Dates and Times in R