Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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