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

Description Usage Arguments Value Examples

View source: R/Rfunctions.R

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")

taRifx documentation built on April 14, 2020, 6:27 p.m.

Related to middle.group in taRifx...