Skip to contents

Retrieves or defines the sample names.

Usage

any_replicated(x)

is_replicated(x)

get_samples(x)

set_samples(x) <- value

# S4 method for CompositionMatrix
is_replicated(x)

# S4 method for LogRatio
is_replicated(x)

# S4 method for OutlierIndex
is_replicated(x)

# S4 method for CompositionMatrix
any_replicated(x)

# S4 method for LogRatio
any_replicated(x)

# S4 method for OutlierIndex
any_replicated(x)

# S4 method for CompositionMatrix
get_samples(x)

# S4 method for LogRatio
get_samples(x)

# S4 method for OutlierIndex
get_samples(x)

# S4 method for CompositionMatrix
set_samples(x) <- value

Arguments

x

An object from which to get or set samples.

value

A possible value for the samples of x.

Value

  • set_samples() returns an object of the same sort as x with the new sample names assigned.

  • get_samples() returns a character vector giving the sample names of x.

  • any_replicated() returns a logical scalar specifying whether or not x has replicated observations.

  • is_replicated() returns a logical vector specifying whether or not an observation is a replicate.

Details

In some situations, measurements may have been repeated (e.g. multiple chemical analyses on the same sample). The presence of repeated measurements can be specified by giving several observations the same sample name.

See vignette("nexus").

See also

Other mutators: groups, split(), subset(), 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, samples = 2, groups = 1)
head(as_features(coda))
#>     sample group    quartz microcline plagioclass    biotite  muscovite
#> A_1      A    A1 0.2467532  0.3556444   0.3326673 0.03296703 0.01998002
#> B_1      B    A1 0.2680000  0.3570000   0.3260000 0.03500000 0.00400000
#> C_1      C    A1 0.2802803  0.3423423   0.3213213 0.03403403 0.01101101
#> D_1      D    A1 0.2780000  0.3500000   0.3150000 0.03300000 0.01000000
#> E_1      E    A1 0.2660000  0.3450000   0.3360000 0.03000000 0.01400000
#> A_2      A    A2 0.2730000  0.3550000   0.3210000 0.02500000 0.01500000
#>         opaques  nonopaques
#> A_1 0.005994006 0.005994006
#> B_1 0.006000000 0.004000000
#> C_1 0.007007007 0.004004004
#> D_1 0.009000000 0.005000000
#> E_1 0.006000000 0.003000000
#> A_2 0.008000000 0.003000000

get_samples(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"
get_groups(coda)
#>  [1] "A1" "A1" "A1" "A1" "A1" "A2" "A2" "A2" "A2" "A2" "A3" "A3" "A3" "A3" "A3"
#> [16] "A4" "A4" "A4" "A4" "A4" "A5" "A5" "A5" "A5" "A5"