Retrieves or defines the (reference) groups to which the observations belong.
Usage
groups(object)
groups(object) <- value
any_assigned(object)
is_assigned(object)
# S4 method for class 'CompositionMatrix'
is_assigned(object)
# S4 method for class 'LogRatio'
is_assigned(object)
# S4 method for class 'CompositionMatrix'
any_assigned(object)
# S4 method for class 'LogRatio'
any_assigned(object)
# S4 method for class 'CompositionMatrix'
groups(object)
# S4 method for class 'LogRatio'
groups(object)
# S4 method for class 'OutlierIndex'
groups(object)
# S4 method for class 'CompositionMatrix,ANY'
groups(object) <- value
# S4 method for class 'CompositionMatrix,list'
groups(object) <- value
Arguments
- object
An object from which to get or set
groups
.- value
A possible value for the
groups
ofx
(typically, acharacter
vector). Ifvalue
is alist
,interaction(value)
defines the grouping.
Value
groups() <- value
returns an object of the same sort asx
with the new group names assigned.groups()
returns acharacter
vector giving the group names ofx
.any_assigned()
returns alogical
scalar specifying whether or notx
has groups.is_assigned()
returns alogical
vector specifying whether or not an observation belongs to a group.
Details
Missing values (NA
) or empty strings (""
) can be used to specify that a
sample does not belong to any group.
Examples
## Data from Aitchison 1986
data("slides")
head(slides)
#> analyst slide quartz microcline plagioclass biotite muscovite opaques
#> 1 A1 A 24.7 35.6 33.3 3.3 2.0 0.6
#> 2 A1 B 26.8 35.7 32.6 3.5 0.4 0.6
#> 3 A1 C 28.0 34.2 32.1 3.4 1.1 0.7
#> 4 A1 D 27.8 35.0 31.5 3.3 1.0 0.9
#> 5 A1 E 26.6 34.5 33.6 3.0 1.4 0.6
#> 6 A2 A 27.3 35.5 32.1 2.5 1.5 0.8
#> nonopaques
#> 1 0.6
#> 2 0.4
#> 3 0.4
#> 4 0.5
#> 5 0.3
#> 6 0.3
## Coerce to compositional data
coda <- as_composition(slides, groups = 2)
groups(coda)
#> Error in x$membership: $ operator is invalid for atomic vectors