Add LENA stats to each interval in a dataframe
add_lena_stats.RdAdd LENA stats to each interval in a dataframe
Usage
add_lena_stats(its_xml, intervals, time_type = c("wall", "wav"))Arguments
- its_xml
XML object created by
rlena::read_its_file.- intervals
A tibble with columns depending on
time_type:For
wall:interval_start,interval_end(POSIXct),interval_start_wav(ms)For
wav:interval_start_wav,interval_end_wav(both in ms since wav start) Can contain other columns.
- time_type
Either
wallorwav. Ifwall(default), expects columnsinterval_start,interval_end(POSIXct timestamps), andinterval_start_wav(milliseconds since wav start). Will calculateinterval_end_wavdynamically and drop it from output. Ifwav, expectsinterval_start_wavandinterval_end_wav(both in milliseconds since wav start).
Value
Same as intervals but with three new columns: cvc, ctc, and
awc. Missing values are replaced with 0 for intervals without segments.
Note
ITS segments overlapping with intervals are allocated proportionally based on the overlap duration. If a segment overlaps multiple intervals, it contributes proportionally to each based on overlap length.
The difference between this function and calculate_lena_like_stats
is that the latter calculates exactly the same stats but does it for every
five minute period of wall time (e.g., 13:00-13:05). It should be rewritten
to first create these intervals and then use add_lena_stats to avoid code
repetition (see issue #).