Skip to contents

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 of x (typically, a character vector). If value is a list, interaction(value) defines the grouping.

Value

  • groups() <- value returns an object of the same sort as x with the new group names assigned.

  • groups() returns a character vector giving the group names of x.

  • any_assigned() returns a logical scalar specifying whether or not x has groups.

  • is_assigned() returns a logical 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.

See also

Other mutators: mutators, totals()

Author

N. Frerebeau

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