group_metrics {swaRmverse}R Documentation

Group Metrics of Collective Motion

Description

This function calculates the average speed, polarization and shape of a group through time.

Usage

group_metrics(data, geo, step2time = 1, parallelize = FALSE)

Arguments

data

A dataframe of (ordered) time series of headings, positions, and speeds per individual. The dataframe may contain several individuals. Should include the columns: id, t, speed, x, y, head, set.

geo

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

step2time

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

parallelize

Logical, whether to parallelize over time. Suggested only for very large datasets.

Value

A dataframe with the group average timeseries, with columns: set, t, pol, speed, shape, N (number of individuals), missing_ind (whether some individuals are missing).

Author(s)

Marina Papadopoulou m.papadopoulou.rug@gmail.com

See Also

group_shape, add_velocities

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(data,
 geo = FALSE,
 step2time = 1)


[Package swaRmverse version 0.1.0 Index]