Learn R Programming

swaRmverse (version 0.1.0)

calc_dur_per_event: Duration of Each Event

Description

This function calculates the duration of each event of collective motion in a dataset.

Usage

calc_dur_per_event(data, step2time)

Value

A dataframe with two columns, event ID and duration in seconds.

Arguments

data

A dataframe with an event column (added by get_event_ids), indicating the event ID that each timestep belongs to. Timesteps that are not part of an event should not be included in the data.

step2time

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

Author

Marina Papadopoulou m.papadopoulou.rug@gmail.com

See Also

events_dur, get_event_ids

Examples

Run this code

data <- data.frame(
set = c(rep('1', 50), rep('2', 50)),
event = c(rep(NA, 10), rep(1, 40), rep(2, 30), rep(NA, 20))
)

time_per_row <- 1 # seconds

calc_dur_per_event(data, time_per_row)

Run the code above in your browser using DataLab