Working in R with Twitter Timestamps

Tweets returned by Twitter’s API contain a timestamp field called “created_at” that cannot be directly read by R. For example, using the default behavior of as.POSIXct(timestamp) produces incorrect internal date representations. Thankfully, formatting the timestamp is simple:

## Assuming your timestamps are located in “timestamps”:
date_format <- “%a %b %d %H:%M:%S %z %Y”
timestamps <- as.POSIXct(strptime(timestamps, date_format, tz = “EST”), tz = “EST”)