cluster_ts: Cluster timestamps

View source: R/cluster.R

cluster_tsR Documentation

Cluster timestamps

Description

Cluster interactions data together as long as they fall into a starting ts + time window length. Independent of badges. Assumes that x is ordered by timestamp (date) field in increasing order. This is useful to group consecutive detects into one continuous session. The "twl" defines the separation in terms of time that needs to pass between sequential detects in order to close one session and start the next.

The literature indicates a timewindow of 2min approx to count an ongoing interaction as one or two separate interactions.

Usage

cluster_ts(x, twl = 120, force.cut = "none", clusterOffset = 1)

## S3 method for class 'smtrx'
cluster_ts(x, twl = 120, force.cut = "none", clusterOffset = 1)

Arguments

x

Dataframe of interaction data.

twl

Integer indicating the length of the time window in seconds within which detects fall into the same cluster. If two detects are further apart in time than twl, a new cluster is created.

force.cut

String, one of c("none", "twl", "nrows", "ncluster"). Default is "none", meaning that cluster reflects timestamp data overlaps, i.e. the session end time expands with each new detect that falls within the time window. If set to "twl" the clusters will be enforced to be of equal duration of twl seconds, independently if subsequent ts detects fall into the same time window. If set to "nrows", twl will be interpreted as number of rows to be included in each cluster. If set to "ncluster", twl will be read as the total number of clusters to be created.

clusterOffset

Integer. Starting number of the cluster count

Value

A data.frame. The original dataframe plus a clusterTS column indicating the group into which the current ts falls

Methods (by class)

  • smtrx: Cluster timestamps of smtrx data

See Also

cluster_ids


jmueller17/sociometrics documentation built on March 20, 2024, 1:04 a.m.