Skip to content

Instantly share code, notes, and snippets.

@eoppe1022
Created November 6, 2018 17:41
Show Gist options
  • Save eoppe1022/a512b686cccc3ba16469183141fbd4ce to your computer and use it in GitHub Desktop.
Save eoppe1022/a512b686cccc3ba16469183141fbd4ce to your computer and use it in GitHub Desktop.
Tweet Markov Bot
library(tidyverse)
library(rtweet)
library(markovifyR)
## Get tweets with "rtweet"
## FYI you need to set up "rtweet" beforehand
yost_data <- get_timeline("@travisyost", n = 10000)
## Take out RTs and create Markov model
markov_model <- yost_data %>%
filter(is_retweet == FALSE) %>%
pull(text) %>%
generate_markovify_model(markov_state_size = 2) %>%
markovify_text(maximum_sentence_length = NULL, count = 25, tries = 100, only_distinct = TRUE)
## Print output
markov_model %>%
print(n = 25)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment