Skip to content

Instantly share code, notes, and snippets.

@rasyidstat
Created April 19, 2017 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rasyidstat/03f31381b4ddf64041398ba7f3372337 to your computer and use it in GitHub Desktop.
Save rasyidstat/03f31381b4ddf64041398ba7f3372337 to your computer and use it in GitHub Desktop.
df_ho %>%
select(-date) %>%
mutate_each(funs(as.POSIXct(paste("2017-01-01", .))), -day) %>%
ggplot(aes(dep_time, arr_time, color=day)) + geom_point() +
geom_smooth(method="lm", color="steelblue") +
theme_ipsum_rc(grid="X") +
labs(title="When do I depart and arrive from home to office?",
subtitle=paste(month(min(df_ho$date), label=T), year(min(df_ho$date)), '-',
month(max(df_ho$date), label=T), year(max(df_ho$date))),
caption=paste("Number of trips from home to main office:", nrow(df_ho)),
x='Departure Time', y='Arrival Time') +
scale_color_discrete(name="Day") +
scale_x_datetime(date_breaks='5 min',
date_labels='%H:%M') +
scale_y_datetime(date_breaks='5 min',
date_labels='%H:%M') +
theme(panel.grid.major.y=element_line())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment