get_shift_graphs | R Documentation |
When called this will construct word shift graphs.
get_shift_graphs( x, text_names = c("Text 1", "Text 2"), top_n = 50L, detailed = FALSE )
x |
A shift object. |
text_names |
The names of the text to compare. Defaults to "Text 1" and "Text 2". |
top_n |
Integer value. Number of words to display in the main graph. Defaults to 50 |
detailed |
Logical. Defaults to "FALSE". By default, the shifts display the overall contributions, rather than the detailed component contributions. By setting this value to "TRUE" the full details of the shifts are visualized. |
Returns the plots of all the shift graphs.
## Not run: library(shifterator) library(quanteda) library(quanteda.textstats) library(dplyr) reagan <- corpus_subset(data_corpus_inaugural, President == "Reagan") %>% tokens(remove_punct = TRUE) %>% dfm() %>% textstat_frequency() %>% as.data.frame() %>% # to move from classes frequency, textstat, and data.frame to data.frame select(feature, frequency) bush <- corpus_subset(data_corpus_inaugural, President == "Bush" & FirstName == "George W.") %>% tokens(remove_punct = TRUE) %>% dfm() %>% textstat_frequency() %>% as.data.frame() %>% select(feature, frequency) prop <- proportion_shift(reagan, bush) # plot the proportion shift graph get_shift_graphs(prop_shift, text_names = c("reagan", "bush")) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.