From: Frederik Vanrenterghem Date: Sat, 8 Sep 2018 11:18:26 +0000 (+0800) Subject: Convert to function. X-Git-Url: http://git.vanrenterghem.biz/R/project-using-kafka-in-R.git/commitdiff_plain/7738dcb24a3d984e70bed41c43b9111c6dcb692e Convert to function. --- diff --git a/predictWebsiteHits.R b/predictWebsiteHits.R index 2a0d66e..415ab1e 100644 --- a/predictWebsiteHits.R +++ b/predictWebsiteHits.R @@ -1,15 +1,10 @@ -library(jsonlite) library(fable) library(tsibble) library(lubridate) library(ggplot2) -logfile <- file("data/photos.vanrenterghem.biz.access.kvp.log.1") - -apachelog <- stream_in(logfile) - -#apachelog$time <- gsub("\\[|\\]", "", apachelog$time) -apachelog %>% +createPlot <- function(x){ +x %>% mutate(time = gsub("\\[|\\]", "", time), time = dmy_hms(time), datehour = floor_date(time, unit = "hour") @@ -26,4 +21,4 @@ apachelog_tsbl %>% autoplot + ggtitle("Forecasting website hits using apache log only") + xlab("Date time") - +} \ No newline at end of file