textplot is a suite of text plotting tools that enable the user to analyze text data via serveral common text plotting methods. Methods include lexical dispersion plots, word trees, speech networks, co-occurrence networks, speech Gantt charts, text hilighting, and word clouds.
To download the development version of textplot:
Download the zip
ball or tar
ball, decompress
and run R CMD INSTALL
on it, or use the pacman package to install
the development version:
if (!require("pacman")) install.packages("pacman")
pacman::p_load_current_gh("trinker/textplot")
if (!require("pacman")) install.packages("pacman")
pacman::p_load(dplyr, magrittr, textplot)
pacman::p_load_current_gh('trinker/numform')
sam_i_am %>%
lexical_dispersion(c(' not ', ' eat ', ' sam ', ' (sam|eat) ')) %>%
plot()
pres_debates2012 %>%
dplyr::filter(person %in% c('ROMNEY', 'OBAMA')) %$%
lexical_dispersion(text.var = dialogue, term.list = wrds,
grouping.var = person, rm.var = time
) %>%
plot() +
ggplot2::scale_x_continuous(labels = numform::ff_denom())
pres_debates2012 %>%
dplyr::filter(person %in% c('ROMNEY', 'OBAMA')) %$%
lexical_dispersion(text.var = dialogue, term.list = wrds,
grouping.var = person, rm.var = time
) %>%
plot(bg.color = "black", grouping.var = list(fam.aff, sex),
color = "yellow", total.color = "white", horiz.color="grey20"
) +
ggplot2::scale_x_continuous(labels = numform::ff_denom())
word_tree(sam_i_am, word = 'I') %>%
plot()
word_tree(sam_i_am, word = 'do') %>%
plot()
presidential_debates_2012 %>%
dplyr::filter(person %in% c('ROMNEY', 'OBAMA')) %$%
word_tree(
text.var = dialogue,
word = 'america',
grouping.var = person
) %>%
plot()
hilighter_cols %>%
view_cols()
map1 <- list(
`#FF69B4` = c('we(\'[a-z]+)?\\b'),
`#7CFC00` = c('he(\'[a-z]+)?\\b'),
yellow = 'you',
gray70 = '\\bi(?=$|\\s)'
)
set.seed(10)
presidential_debates_2012 %>%
dplyr::filter(person %in% c('ROMNEY', 'OBAMA')) %>%
dplyr::group_by(person) %>%
dplyr::sample_n(15) %$%
hilight_term(dialogue, map1, list(person)) %>%
plot()
map2 <- list(
`#FF69B4` = c('talk', 'you'),
`#7CFC00` = c('he', "he's"),
orange = c('we\'re', 'we'),
yellow = 'that',
gray70 = c('.', '?', '!')
)
set.seed(10)
presidential_debates_2012 %>%
dplyr::filter(person %in% c('ROMNEY', 'OBAMA')) %>%
dplyr::group_by(person) %>%
dplyr::sample_n(15) %$%
hilight_token(dialogue, map2, list(person)) %>%
plot()
map3 <- list(
'think',
c('he is', "he's", 'you(\'[vr]e)?\\b'),
'\\bi\\b'
) %>%
map_cols(rev(hilighter_cols))
set.seed(10)
presidential_debates_2012 %>%
dplyr::filter(person %in% c('ROMNEY', 'OBAMA')) %>%
dplyr::group_by(person) %>%
dplyr::sample_n(15) %$%
hilight_sentence(dialogue, map3, list(person)) %>%
plot()
You are welcome to:
- submit suggestions and bug-reports at: https://github.com/trinker/textplot/issues
- send a pull request on: https://github.com/trinker/textplot/
- compose a friendly e-mail to: tyler.rinker@gmail.com