Plot State Frequencies as a Mosaic Between Two Groups
Usage
# S3 method for class 'tna_data'
plot_mosaic(x, group, label = "Group", digits = 1, ...)
Arguments
- x
A
tna_data
object.- group
A
character
string giving the column name of the (meta) data to contrast the frequencies with or a vector of group indicators with the the same length as the number of rows in the sequence data.- label
An optional
character
string that specifies a label for the grouping variable whengroup
is not a column name of the data.- digits
An
integer
that determines the number of digits to use for the chi-square test statistic and the p-value in the plot.- ...
Ignored.
See also
Basic functions
build_model()
,
hist.group_tna()
,
hist.tna()
,
plot.group_tna()
,
plot.tna()
,
plot_mosaic()
,
plot_mosaic.group_tna()
,
prepare_data()
,
print.group_tna()
,
print.summary.group_tna()
,
print.summary.tna()
,
print.tna()
,
print.tna_data()
,
summary.group_tna()
,
summary.tna()
,
tna-package
Examples
d <- data.frame(
time = rep(1:5, rep = 4),
group = rep(1:4, each = 5),
event = sample(LETTERS[1:3], 20, replace = TRUE)
)
sequence_data <- prepare_data(
d,
time = "time",
actor = "group",
action = "event"
)
#>
#> Initializing session computation...
#>
#> Input data dimensions: 20 rows, 3 columns
#>
#> Parsing time values...
#>
#> First few time values: 1, 2, and 3
#>
#> Detected <numeric> time values - treating as Unix timestamp.
#>
#> Starting time parsing process...
#>
#> Number of values to parse: 20
#>
#> Sample values: 1, 2, and 3
#>
#> Sample of parsed times: 1970-01-01 00:00:01, 1970-01-01 00:00:02, and
#> 1970-01-01 00:00:03
#>
#> Creating sessions based on time threshold...
#>
#> Time threshold for new session: 900 seconds
#>
#> Creating wide format view of sessions...
#>
#> Session Analysis Summary
#>
#> ------------------------
#>
#> Total number of sessions: 4
#>
#> Number of unique users: 4
#>
#> Total number of actions: 20
#>
#> Maximum sequence length: 5 actions
#>
#> Time range: 1970-01-01 00:00:01 to 1970-01-01 00:00:05
#>
#> Sessions per user:
#> # A tibble: 4 × 2
#> group n_sessions
#> <int> <int>
#> 1 1 1
#> 2 2 1
#> 3 3 1
#> 4 4 1
#>
#> Top 5 longest sessions:
#> # A tibble: 4 × 2
#> .session_id n_actions
#> <chr> <int>
#> 1 1 session1 5
#> 2 2 session1 5
#> 3 3 session1 5
#> 4 4 session1 5
plot_mosaic(sequence_data, group = "group")