Skip to content

Instantly share code, notes, and snippets.

@monogenea
Created October 7, 2019 16:00
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 monogenea/e9d099891178d8b6059286c96d398663 to your computer and use it in GitHub Desktop.
Save monogenea/e9d099891178d8b6059286c96d398663 to your computer and use it in GitHub Desktop.
# Tokenize words
tkn <- tokens(allTweets$text,
remove_twitter = T,
remove_separators = T,
remove_symbols = T,
remove_punct = T,
remove_url = T,
remove_hyphens = T,
remove_numbers = T) %>%
tokens_ngrams(n = 1:2)
gotDfm <- dfm(tkn, tolower = T,
remove = stopwords("english"))
gotChars <- c("jon", "cersei", "sansa", "arya",
"bran", "tyrion", "jaime", "daenerys",
"hound", "davos", "missandei", "theon",
"brienne", "gendry", "grey_worm", "jorah",
"night_king", "varys", "melisandre", "tormund")
gotFcm <- dfm_select(gotDfm, pattern = gotChars) %>%
fcm()
set.seed(100)
textplot_network(gotFcm, min_freq = 0.1,
edge_alpha = .25,
edge_size = 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment