Skip to contents

This function summarizes the number of events and their total duration in the dataset.

Usage

events_summary(data, step2time)

Arguments

data

A dataframe with a keep column (representing which rows are defined as events of collective motion) and a set column.

step2time

The sampling frequency of the dataframe (how many seconds are between each row of the data).

Value

A dataframe with 3 columns: set, ev_count (number of events), and dur (duration of events in seconds).

See also

Author

Marina Papadopoulou m.papadopoulou.rug@gmail.com

Examples


data <- data.frame(
set = c(rep('1', 50), rep('2', 50)),
keep = c(rep(FALSE, 10), rep(TRUE, 70), rep(FALSE, 20))
)

time_per_row <- 1 # seconds

events_summary(data, time_per_row)
#>   set ev_count dur
#> 1   1        1  40
#> 2   2        1  30