Extracts the overall duration during which an inner_col in a movement or eye tracker tibble took its unique values. This generalises the notion of a frequency table to account for potentially uneven sampling and can be handy for example to extract fixation durations from an eye tracker tibble. This function works differently from other extract_... function in that it returns a tibble, not a scalar value (and NULL rather than NA_real_ in case of invalid input)

extract_durations(df, inner_col, min_time = 0, max_time = Inf)

Arguments

df

Any tibble with columns time and inner_col

inner_col

Any column in df (character)

min_time

minimum time in s (default trial start)

max_time

maximum time in s (default trial end)

Value

The table of durations for each value in the inner_col in descending order

Details

Each row in which a value is observed adds to the duration of that value half the time interval to the previous timestamp and half the time interval to the next timestamp.