View source: R/grouping-functions.R
groupClosest | R Documentation |
Group values with a difference between them being smaller than a user
defined threshold. This function uses the groupSimilarityMatrix()
or the
groupSimilarityMatrixTree()
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).
groupClosest(x, maxDiff = 1, FUN = groupSimilarityMatrix, ...)
x |
|
maxDiff |
|
FUN |
supported similarity calculation function. Can be either groupSimilarityMatrix (the default) or groupSimilarityMatrixTree, the latter being faster and less memory demanding. |
... |
additional parameters passed to |
integer
with the group assignment (values grouped together have
the same return value).
Johannes Rainer, Johan Lassen
Other grouping operations:
groupConsecutive()
,
groupSimilarityMatrix()
,
groupSimilarityMatrixTree()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.