group_metrics_per_set {swaRmverse}R Documentation

Group Metrics of Collective Motion in a Dataset

Description

This function calculates the timeseries of average speed, polarization and shape of all set in a dataset

Usage

group_metrics_per_set(
  data_list,
  mov_av_time_window,
  geo,
  step2time,
  parallelize = FALSE
)

Arguments

data_list

A list of dataframes with groups timeseries per set. Columns must include: id, t, set, head, x, y, speed.

mov_av_time_window

Integer, timesteps to use as a sliding window for average speed and polarization.

geo

Logical, whether positions are geographic coordinates, default = FALSE.

step2time

Double, the sampling frequency of the data (the relation between a time step and real time in seconds).

parallelize

Logical, whether or not to parallelize over the timesteps of each set.

Value

A dataframe with the group average timeseries for each set, with columns: set, t, pol, speed, shape, N (number of individuals), missing_ind (whether some individuals are missing), pol_av (moving average of polarization based on input time window) and speed_av (moving average of speed based on input time window).

Author(s)

Marina Papadopoulou m.papadopoulou.rug@gmail.com

See Also

group_metrics, moving_average

Examples


data <- data.frame(
 set = rep("1", 50),
 t = as.POSIXct(rep(1:25, 2), origin = Sys.time()),
 id = c(rep(1, 25), rep(2, 25)),
 x = rnorm(50),
 y = rnorm(50),
 head = runif(50, 0, 2 * pi),
 speed = rnorm(50)
 )

gm <- group_metrics_per_set(list(data),
 mov_av_time_window = 5,
 geo = FALSE,
 step2time = 1
 )

[Package swaRmverse version 0.1.0 Index]