Skip to content

Instantly share code, notes, and snippets.

@wheresalice
Last active January 3, 2019 08:51
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 wheresalice/ae32fb19a785f3a97a90060ae8b30e07 to your computer and use it in GitHub Desktop.
Save wheresalice/ae32fb19a785f3a97a90060ae8b30e07 to your computer and use it in GitHub Desktop.
Predict future growth of your Slack org using R and Facebook's Prophet library
library("prophet")
# Import the CSV file generated from my.slack.com/stats
slack <- read.csv("~/tmp/slack.csv")
# Do some cleaning up
clean_slack <- slack[slack$Total.Users != 0,]
dates <- as.POSIXct(strptime(clean_slack$Date, "%Y-%m-%d"))
# Pick which variable to predict (Total.Users is most useful)
prophet_df <- data.frame(dates, clean_slack$Total.Users)
# Make a dataframe that prophet is happy with
names(prophet_df) =c("ds","y")
m <- prophet(prophet_df)
# Predict the next two years
future = make_future_dataframe(m, periods = 365 * 2)
forecast = predict(m, future)
# Generate a dataframe with predicted values
future_df <- forecast[c('ds', 'yhat', 'yhat_lower', 'yhat_upper')]
# Plot the graph
plot(m, forecast)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment