Create a Sequence Index Plot or a Distribution Plot
Usage
plot_sequences(x, ...)
# S3 method for class 'tna'
plot_sequences(
x,
group,
type = "index",
scale = "proportion",
geom = "bar",
include_na = TRUE,
na_color = "white",
sort_by,
show_n = TRUE,
border,
title,
legend_title,
xlab,
ylab,
tick = 1,
...
)
# S3 method for class 'tna_data'
plot_sequences(
x,
group,
type = "index",
scale = "proportion",
geom = "bar",
include_na = FALSE,
colors,
na_color = "white",
sort_by,
show_n = TRUE,
border,
title,
legend_title,
xlab,
ylab,
tick = 1,
...
)
# Default S3 method
plot_sequences(
x,
cols,
group,
type = "index",
scale = "proportion",
geom = "bar",
include_na = FALSE,
colors,
na_color = "white",
sort_by,
show_n = TRUE,
border,
title,
legend_title,
xlab,
ylab,
tick = 1,
...
)
# S3 method for class 'group_tna'
plot_sequences(
x,
type = "index",
scale = "proportion",
geom = "bar",
include_na = FALSE,
na_color = "white",
sort_by,
show_n = TRUE,
border,
title,
legend_title,
xlab,
ylab,
tick = 1,
...
)
Arguments
- x
A
tna
,group_tna
,tna_data
or adata.frame
object with sequence data in wide format.- ...
Ignored.
- group
A vector indicating the group assignment of each row of the data. Must have the same length as the number of rows of
x
. Alternatively, a singlecharacter
string giving the column name of the data that defines the group whenx
is a wide formatdata.frame
or atna_data
object. Used for faceting the plot.- type
A
character
string for the type of plot to generate. The available options are"index"
(the default) for a sequence index plot, and"distribution"
showing the distribution of the states over time.- scale
A
character
string that determines the scaling of the vertical axis for distribution plots. The options are"proportion"
(the default) and"count"
for proportions and raw counts of states, respectively.- geom
A
character
string for the type of geom to use for distribution plots. The options are"bar"
(the default) and"area"
.- include_na
A
logical
value for whether to include missing values for distribution plots. The default isTRUE
: missing values are converted to a new state and included in the plot.- na_color
A
character
string giving the color to use for missing values. The default is"white"
.- sort_by
Either a
character
vector of column names ofx
to sort by or"everything"
to sort by every column. If missing, no sorting is done.- show_n
A
logical
value for whether to add the number of observations (total or by group) to the plot title.- border
A
character
string giving the color for borders. For index plots, this is the color of borders between cells (tiles). For distribution plot withgeom = "bar"
, this is the color of bar outlines. Not applicable togeom = "area"
.- title
An optional
character
string providing a title for the plot.- legend_title
An optional
character
string providing a title for the legend.- xlab
A
character
string giving the label for the horizontal axis. The default is"Time"
.- ylab
A
character
string giving the label for the vertical axis. The default is"Sequence"
for index plots, and"Proportion"
or"Count"
based onscale
for distribution plots.- tick
An
integer
specifying the horizontal axis label interval, e.g.,tick = 5
would show every 5th label. The default is 1 showing every label.- colors
A named
character
vector mapping states to colors, or an unnamedcharacter
vector. If missing, a default palette is used.- cols
A
character
Vector of column names to be treated as time points. If missing, all columns will be used.