Rlang - nimrody/knowledgebase GitHub Wiki

Rlang

  • options(error=recover) which drops you into a nice lispy stack

  • devtools - package for simplifying working with packages

  • ggplot flipbook

  • Set the default timezone to UTC

    Sys.setenv(TZ='GMT')

  • Plots vs time

    require(ggplot2) require(scales) ggplot(subset(x, time>'2017-05-15'), aes(x=time, y=updates)) + geom_line()+scale_x_datetime(breaks = date_breaks('1 day'), minor_breaks = date_breaks('6 hour'))

  • Create date from numbers - use ISOdate or datetime from numbers - use ISOdatetime

  • Parse time line Jul 18, 2016 11:43:10 PM into datetime object

    x$time<-as.POSIXct(x$V1, format='%b %d, %Y %I:%M:%S %p')

    (see here for a function that automatically determines the format and here for information on POSIXct)

  • Parse epoch (seconds!) into time

    x$time <- as.POSIXct(x$V1, origin="1970-01-01") # may add tz='GMT'

  • ggplot tutorial

  • Group by date and sum

    require(dplyr) x$time <- as.POSIXct(x$time) x$date <- as.Date(x$time) x %>% group_by(date) %>% summarise(size = sum(downloadSize)/1e6) # use =n() for counting

  • Set ylimit, xlimit (effectively zoom)

    • coord_cartesian(ylim=c(-12,12))

Interesting resources