Convert to function.
[R/project-using-kafka-in-R.git] / predictWebsiteHits.R
index 2a0d66e2e6f96b429a07495d91a92ce5bcb27aba..415ab1eebdedd0c32e88170e91b78bedd866f1b2 100644 (file)
@@ -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