segment_annotations: segment annotations time-based intervals

Description Usage Arguments Details Value Examples

View source: R/segment_annotations.R

Description

assign each annotation to regular (e.g. one minute) segments

Usage

1
segment_annotations(xdata, segment_dur, timecols = c("start", "end"))

Arguments

xdata

data.frame, the data object with annotations (e.g. import from ELAN or .rttm file)

segment_dur

numeric, the time interval in the relevant unit (no default, see details)

timecols

character, the column names for start and end of the annotations (default is c("start", "end")).

Details

note that annotations that cross over a given cut point for a segment will be split into two (or more if an annotation is much longer than the segment duration)

Value

a data.frame with a new column cat that indicates which time interval a given annotation belongs to

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
annos <- LETTERS[1:5]
start <- c(14, 17, 45, 65, 70)
end <- c(25, 22, 60, 80, 73)
dur <- end - start
xdata <- data.frame(start, end, dur, annos)

xdata
segment_annotations(xdata, segment_dur = 10, timecols = c("start", "end"))

# from an ELAN file:
eaf <- system.file("synthetic_speech.eaf", package = "avutils")
elanfile <- read_elan(eaf)
segment_annotations(elanfile, segment_dur = 0.5)

gobbios/avutils documentation built on Feb. 19, 2020, 9:44 a.m.