groupClosest: Group values with differences below threshold

View source: R/grouping-functions.R

groupClosestR Documentation

Group values with differences below threshold

Description

Group values with a difference between them being smaller than a user defined threshold. This function uses the groupSimilarityMatrix() function to create groups with smallest differences between its members. Differences between all members of one group are below the user defined threshold maxDiff. This is a more stringent grouping than what groupConsecutive() performs leading thus to smaller groups (with smaller differences between its members).

Usage

groupClosest(x, maxDiff = 1)

Arguments

x

numeric of values that should be grouped.

maxDiff

numeric(1) defining the threshold for difference between values in x to be grouped into the same group.

Value

integer with the group assignment (values grouped together have the same return value).

Author(s)

Johannes Rainer

See Also

Other grouping operations: groupConsecutive(), groupSimilarityMatrix()

Examples


x <- c(1.1, 1.9, 2.2)
groupClosest(x)
## Although the difference between the 1st and 2nd element would be smaller
## than the threshold, they are not grouped because the difference between
## the 2nd and 3rd element is even smaller. The first element is also not
## put into the same group, because it has a difference > diffRt to the 3rd
## element.

x <- c(1.1, 1.5, 1.7, 2.3, 2.7, 4.3, 4.4, 4.9, 5.2, 5.4, 5.8, 6, 7,
    9, 9.5, 15)

groupClosest(x)

rformassspectrometry/MsFeatures documentation built on April 21, 2023, 6:20 a.m.