Last active
October 2, 2019 15:07
-
-
Save mpkocher/c404ad308dbbdf0919152747e71c24a7 to your computer and use it in GitHub Desktop.
Example of Plotting TimeStamps in R using the SL log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(lubridate) | |
library(dplyr) | |
library(readr) | |
library(ggplot2) | |
process_log <- function(csv_path, output_png, custom_title) { | |
# CSV with a single column "request_time" with the UTC time of the request time stamp | |
tdf <- read_csv(csv_path) | |
rdf <- tdf %>% transmute(created_at = ymd_hms(request_time)) | |
# per day | |
binwidth <- 60 * 60 * 24 | |
plot_title <- paste0("Request Per Day ", custom_title) | |
rdf %>% filter(created_at >= ymd("2017-1-1")) %>% ggplot(aes(created_at)) + geom_freqpoly(binwidth=binwidth) + ggtitle(plot_title) | |
ggsave(output_png) | |
return(output_png) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment