Skip to contents

When called this will construct word shift graphs.

Usage

get_shift_graphs(
  x,
  text_names = c("Text 1", "Text 2"),
  top_n = 50L,
  detailed = FALSE
)

Arguments

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.

Value

Returns the plots of all the shift graphs.

Examples

if (FALSE) {
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"))
}