Skip to content

Instantly share code, notes, and snippets.

@labeneator
Created December 31, 2013 20:41
Show Gist options
  • Save labeneator/8202029 to your computer and use it in GitHub Desktop.
Save labeneator/8202029 to your computer and use it in GitHub Desktop.
# Conversion of unix timestamps to POSIXct
> as.POSIXct(1388512551, origin="1970-01-01 00:00:00")
[1] "2013-12-31 19:55:51 SAST"
# ggplot of POSIXct.
# pdt_time is of POSIXct type
> m <- ggplot(df, aes(pdt_time, some_count)) + geom_point(aes(colour=as.factor(some_factor)))
> m
# Pretty printing datetimes. Major breaks with an axis label every 30 minutes
> m <- m + scale_x_datetime(breaks = date_breaks("30 min"), labels = date_format("%H:%M"))
# Rotate the text labels. Decongests the x axis labels
> m <- m + opts(axis.text.x=theme_text(angle=90, hjust=1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment