Learn R Programming

nexus (version 0.3.0)

subset: Extract or Replace Parts of an Object

Description

Operators acting on objects to extract or replace parts.

Usage

# S4 method for CompositionMatrix,missing,missing,missing
[(x, i, j, ..., drop = TRUE)

# S4 method for CompositionMatrix,missing,missing,logical [(x, i, j, ..., drop = TRUE)

# S4 method for CompositionMatrix,index,missing,missing [(x, i, j, ..., drop = TRUE)

# S4 method for CompositionMatrix,index,missing,logical [(x, i, j, ..., drop = TRUE)

# S4 method for CompositionMatrix,missing,index,missing [(x, i, j, ..., drop = TRUE)

# S4 method for CompositionMatrix,missing,index,logical [(x, i, j, ..., drop = TRUE)

# S4 method for CompositionMatrix,index,index,missing [(x, i, j, ..., drop = TRUE)

# S4 method for CompositionMatrix,index,index,logical [(x, i, j, ..., drop = TRUE)

# S4 method for CompositionMatrix [(x, i, j, ...) <- value

# S4 method for CompositionMatrix [[(x, i, j, ...) <- value

Value

A subsetted object of the same sort as x.

Arguments

x

An object from which to extract element(s) or in which to replace element(s).

i, j

Indices specifying elements to extract or replace. Indices are numeric, integer or character vectors or empty (missing) or NULL. Numeric values are coerced to integer as by as.integer(). Character vectors will be matched to the name of the elements. An empty index (a comma separated blank) indicates that all entries in that dimension are selected.

...

Currently not used.

drop

A logical scalar: should the result be coerced to the lowest possible dimension? This only works for extracting elements, not for the replacement. Defaults to FALSE.

value

A possible value for the element(s) of x.

Author

N. Frerebeau

See Also

Other subsetting methods: bind, extract(), split()

Examples

Run this code
## Data from Aitchison 1986
data("hongite")

## Coerce to compositional data
coda <- as_composition(hongite)
head(coda)

## Subset
coda[[1, 1]] # Get the first value
coda[1] # Get the first value
coda[, ] # Get all values
coda[1, ] # Get the first row

## Subcomposition
subcoda <- coda[, 1:3] # Get the first three column
head(subcoda)

Run the code above in your browser using DataLab