Skip to contents

Retrieve the (reference) groups to which the observations belong.

Usage

group_levels(object)

group_names(object)

group_rows(object)

group_length(object)

group_size(object)

group_indices(object)

is_assigned(object)

any_assigned(object)

all_assigned(object)

# S4 method for class 'ReferenceGroups'
group_levels(object)

# S4 method for class 'ReferenceGroups'
group_names(object)

# S4 method for class 'ReferenceGroups'
group_indices(object)

# S4 method for class 'ReferenceGroups'
group_rows(object)

# S4 method for class 'ReferenceGroups'
group_length(object)

# S4 method for class 'ReferenceGroups'
group_size(object)

# S4 method for class 'ReferenceGroups'
is_assigned(object)

# S4 method for class 'ReferenceGroups'
any_assigned(object)

# S4 method for class 'ReferenceGroups'
all_assigned(object)

Arguments

object

A grouped R object.

Functions

  • group_levels(ReferenceGroups): returns a character vector giving the group names.

  • group_names(ReferenceGroups): returns a character vector giving the name of the group that each observation belongs to.

  • group_indices(ReferenceGroups): returns an integer vector giving the group that each value belongs to.

  • group_rows(ReferenceGroups): returns a list of integer vectors giving the observation that each group contains.

  • group_length(ReferenceGroups): gives the total number of groups.

  • group_size(ReferenceGroups): gives the size of each group.

  • is_assigned(ReferenceGroups): returns a logical vector specifying whether or not an observation belongs to a group.

  • any_assigned(ReferenceGroups): returns an logical scalar specifying if any observation belongs to a group.

  • all_assigned(ReferenceGroups): returns an logical scalar specifying if all observations belong to a group.

See also

Other grouping methods: group(), group_extract(), group_split()

Author

N. Frerebeau

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_length(coda)
#> [1] 5

group_size(coda)
#> A B C D E 
#> 5 5 5 5 5