Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Forecast website sessions from a CSV document
# Install/Library these functions:
library(forecast)
library (tidyr)
library (dplyr)
library (highcharter)
Upload Excel CSV file to R
aa_data <- read.csv("~/[name of file].csv", stringsAsFactors = FALSE, header = TRUE, sep = ",")
# Check data structure of uploaded data
str(aa_data$sessions)
# Convert dates from characters to integers or numeric (may not apply to all data sets)
yearMonth <- c("yearMonth")
# Identify the column, start and end dates, and that new data should be in months
aa_ts <- ts(aa_data$sessions, start = c(2010,02), end = c(2016,12), frequency = 12)
# Apply Holt Winters forecast model to data
forecast1 <- HoltWinters(aa_ts)
# Forecast for next 36 months
hchart(forecast(forecast1, h = 36))
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.