When an event log records several codes per unit, such as several codes in
one message, a transition joins either two codes of the same unit or the
last code of one unit and the first of the next. The first kind describes
how a unit is composed, the second the move from one unit to the next (a
turn). transition_scope() counts both for every transition, sorting the
events as build_network() does.
Usage
transition_scope(
data,
action,
actor,
unit,
time = NULL,
order = NULL,
edges = NULL,
by_edge = TRUE
)Arguments
- data
Data frame of events, one row per event.
- action, actor
Character. The event column and the column that defines a sequence, as in
build_network().- unit
Character. The column whose equal consecutive values mark one unit, such as a message id.
- time, order
Character or
NULL. The columns that sort the events within a sequence: bytime, ties broken byorder.NULLkeeps the row order. A charactertimeis read as a UTC date-time.- edges
NULL, or a data frame withfromandtocolumns (such as atransition_effects()table): the rows for those transitions, in that order.- by_edge
Logical.
TRUE(default) one row per transition;FALSEone row for all transitions.
Value
A data frame with one row per transition: from, to,
transitions, within (inside one unit), between (across units) and
share_within, sorted by transitions. With by_edge = FALSE, one row
with the same counts over all transitions.
Examples
events <- data.frame(
chat = c(1, 1, 1, 1, 2, 2, 2),
message = c(1, 1, 2, 3, 4, 5, 5),
code = c("ask", "code", "explain", "ask", "ask", "explain", "example"))
transition_scope(events, action = "code", actor = "chat", unit = "message")
#> from to transitions within between share_within
#> 1 ask code 1 1 0 1
#> 2 ask explain 1 0 1 0
#> 3 code explain 1 0 1 0
#> 4 explain ask 1 0 1 0
#> 5 explain example 1 1 0 1
transition_scope(events, action = "code", actor = "chat", unit = "message",
by_edge = FALSE)
#> transitions within between share_within
#> 1 5 2 3 0.4