Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jlouis
Created May 8, 2019 17:26
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 jlouis/5897b8b4e40e56d8726a123da4ed1390 to your computer and use it in GitHub Desktop.
Save jlouis/5897b8b4e40e56d8726a123da4ed1390 to your computer and use it in GitHub Desktop.
## Libraries we are going to need
library(tidyverse)
library(lubridate)
## Load in the data set
vdecls <- readxl::read_xlsx("stramkurs.xlsx", col_types=c("date"))
## Fixup the data set, since Excel is utter crap. There are some NA values, get
## rid of those
vdecls <- filter(vdecls, !is.na(vdecls))
## The name of the column is rather irritating, fixup
vdecls <- rename(vdecls, timestamp = ends_with("Kurs"))
## Kernel density
p <- ggplot(vdecls, aes(timestamp))
p + geom_density()
ggsave("density.png")
## Hours and weekdays are extracted so we can plot those
times <- vdecls %>%
mutate(hour = hour(timestamp),
wday = wday(timestamp, label=TRUE, abbr = TRUE))
p <- ggplot(times, aes(hour))
p + geom_histogram(stat="count")
ggsave("hourly.png")
p <- ggplot(times, aes(hour))
p + geom_histogram(stat="count") + facet_grid(rows = vars(wday))
ggsave("per_wday.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment