Skip to contents

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

Usage

is_assigned(object)

any_assigned(object)

all_assigned(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.

Value

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

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

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

See also

Other grouping methods: group(), group_names(), group_split(), group_subset()

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

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