middle.group: Return a vector containing the locations of the middle of...

Description Usage Arguments Value Examples

Description

This function uses run length encoding to determine the middle of every group of repeated values within a larger vector.

Usage

1
  middle.group(vec, type = "tf")

Arguments

vec

Any vector which you want to know the middle of.

type

Either "tf" to return a boolean or "loc" to return a set of numerical locations.

Value

If type=="tf": Boolean of length length(vec) containing TRUE if the middle of a grouping and FALSE if not. If type=="loc": Vector of length equal to the number of groups in vec, containing locations of the group centers. Ties (for groups of even length) are broken by rounding up.

Examples

1
2
3
test <- c(1,2,2,2,2,2,2,2,2,2,1)
middle.group(test)
middle.group(test,type="loc")

gsk3/taRifx documentation built on May 17, 2019, 8:55 a.m.