from_to
- Add the next speaker as the from variable in a to/from
network data structure. Assumes that the flow of discourse is coming from
person A to person B, or at the very least the talk is taken up by person B.
Works by taking the vector of speakers and shifting everything down one and
then adding a closing element.
from_to_summarize
- A wrapper for from_to.data.frame
that
adds a word.count
column and then combines duplicate rows.
from_to(x, ...)# S3 method for default
from_to(x, final = "End", ...)
# S3 method for character
from_to(x, final = "End", ...)
# S3 method for numeric
from_to(x, final = "End", ...)
# S3 method for data.frame
from_to(x, from.var, final = "End", ...)
from_to_summarize(x, from.var, id.vars = NULL, text.var = TRUE, ...)
A data form vector
or data.frame
.
The name of the closing element or node.
A character string naming the column to be considered the origin of the talk.
The variables that correspond to the speaker or are attributes of the speaker (from variable).
The name of the text variable. If TRUE
duration
tries to detect the text column.
Ignored.
Returns a vector (if given a vector) or an augmented
data.table
.
# NOT RUN {
from_to(DATA, 'person')
from_to_summarize(DATA, 'person')
from_to_summarize(DATA, 'person', c('sex', 'adult'))
# }
# NOT RUN {
if (!require("pacman")) install.packages("pacman"); library(pacman)
p_load(dplyr, geomnet, qdap, stringi, scales)
p_load_current_gh('trinker/textsahpe')
dat <- from_to_summarize(DATA, 'person', c('sex', 'adult')) %>%
mutate(words = rescale(word.count, c(.5, 1.5)))
dat %>%
ggplot(aes(from_id = from, to_id = to)) +
geom_net(
aes(linewidth = words),
layout.alg = "fruchtermanreingold",
directed = TRUE,
labelon = TRUE,
size = 1,
labelcolour = 'black',
ecolour = "grey70",
arrowsize = 1,
curvature = .1
) +
theme_net() +
xlim(c(-0.05, 1.05))
# }
Run the code above in your browser using DataLab