pivot_textgrid_tiers | R Documentation |
Pivot a textgrid into wide format, respecting nested tiers
pivot_textgrid_tiers(data, tiers, join_cols = "file")
data |
a textgrid dataframe created with |
tiers |
character vector of tiers to pivot into wide format. When
|
join_cols |
character vector of the columns that will uniquely identify
a textgrid file. Defaults to |
For the joining nested intervals, two intervals a and b are combined into
the same row if they match on the values in the join_cols
columns and if
the a$xmin <= b$xmid
and b$xmid <= a$xmax
. That is, if the midpoint of
b is contained inside the interval a.
a dataframe with just the intervals from tiers named in tiers
converted into a wide format. Columns are renamed so that the text
column
is pivot into columns named after the tier names. For example, the text
column in a words
tier is renamed to words
. The xmax
, xmin
,
annotation_num
, tier_num
, tier_type
are also prefixed with the tier
name. For example, the xmax
column in a words
tier is renamed to
words_xmax
. An additional helper column xmid
is added and prefixed
appropriately. See examples below.
data <- example_textgrid(3) |>
read_textgrid()
data
# With a single tier, we get just that tier with the columns prefixed with
# the tier_name
pivot_textgrid_tiers(data, "utterance")
pivot_textgrid_tiers(data, "words")
# With multiple tiers, intervals in one tier that contain intervals in
# another tier are combined into the same row.
a <- pivot_textgrid_tiers(data, c("utterance", "words"))
cols <- c(
"utterance", "utterance_xmin", "utterance_xmax",
"words", "words_xmin", "words_xmax"
)
a[cols]
a <- pivot_textgrid_tiers(data, c("utterance", "words", "phones"))
cols <- c(cols, "phones", "phones_xmin", "phones_xmax")
a[cols]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.