elements: Extract the elements of an array specified by the subscripts

elementsR Documentation

Extract the elements of an array specified by the subscripts

Description

Elements of the array x corresponding to the rows of the two dimensional object subscripts are extracted. The number of columns of subscripts corresponds to the number of dimensions of x. The effect of supplying less columns in subscripts than the number of dimensions in x is the same as for "[".

Usage

elements(x, subscripts)

Arguments

x

An array with at least two dimensions whose elements are to be extracted.

subscripts

A two dimensional object interpreted as elements by dimensions.

Value

A vector containing the extracted elements and whose length equals the number of rows in the subscripts object.

Author(s)

Chris Brien

See Also

Extract

Examples

## Form a table of the means for all combinations of Row and Line.
## Then obtain the values corresponding to the combinations in the data frame x,
## excluding Row 3.
x <- fac.gen(list(Row = 2, Line = 4), each =2)
x$y <- rnorm(16)
RowLine.tab <- tapply(x$y, list(x$Row, x$Line), mean)
xs <- elements(RowLine.tab, subscripts=x[x$"Line" != 3, c("Row", "Line")])

dae documentation built on June 22, 2024, 9:07 a.m.