Retrieve the (reference) groups to which the observations belong.
Usage
group_names(object)
group_levels(object)
group_factor(object, ...)
group_rows(object)
group_n(object)
group_size(object)
group_indices(object)
# S4 method for class 'ReferenceGroups'
group_levels(object)
# S4 method for class 'ReferenceGroups'
group_names(object)
# S4 method for class 'ReferenceGroups'
group_factor(object, exclude = NA)
# S4 method for class 'ReferenceGroups'
group_indices(object)
# S4 method for class 'ReferenceGroups'
group_rows(object)
# S4 method for class 'ReferenceGroups'
group_n(object)
# S4 method for class 'ReferenceGroups'
group_size(object)
Value
group_levels()
returns acharacter
vector giving the group names.group_size()
returns aninteger
vector giving the size of each group.group_n()
gives the total number of groups.group_names()
returns acharacter
vector giving the name of the group that each observation belongs to.group_factor()
returns afactor
vector giving the name of the group that each observation belongs to.group_indices()
returns aninteger
vector giving the group that each value belongs to.group_rows()
returns alist
ofinteger
vectors giving the observation that each group contains.
See also
Other grouping methods:
group()
,
group_split()
,
group_subset()
,
is_assigned()
Examples
## Data from Aitchison 1986
data("slides")
## Coerce to compositional data
coda <- as_composition(slides, groups = 2)
## Grouping metadata
group_levels(coda)
#> [1] "A" "B" "C" "D" "E"
group_names(coda)
#> [1] "A" "B" "C" "D" "E" "A" "B" "C" "D" "E" "A" "B" "C" "D" "E" "A" "B" "C" "D"
#> [20] "E" "A" "B" "C" "D" "E"
group_indices(coda)
#> [1] 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
group_rows(coda)
#> $A
#> [1] 1 6 11 16 21
#>
#> $B
#> [1] 2 7 12 17 22
#>
#> $C
#> [1] 3 8 13 18 23
#>
#> $D
#> [1] 4 9 14 19 24
#>
#> $E
#> [1] 5 10 15 20 25
#>
group_n(coda)
#> [1] 5
group_size(coda)
#> A B C D E
#> 5 5 5 5 5