Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
df_ho %>%
select(-date, -day) %>%
gather(key = type, value = time) %>%
mutate(time = as.POSIXct(paste("2017-01-01", time))) %>%
ggplot(aes(time, fill=type)) + geom_density(color=NA, alpha=0.4) +
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=NULL, y=NULL) +
scale_fill_discrete(name="", labels=c('Arrival','Departure')) +
scale_x_datetime(limits=c(as.POSIXct(paste("2017-01-01", "07:35")),
as.POSIXct(paste("2017-01-01", "08:40"))),
date_breaks='5 min',
date_labels='%H:%M') +
theme(legend.justification=c(1,1), legend.position=c(1,1),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.