brackets: Extract or replace Parts of a Multi-Header Data Frame

[[.mlth.data.frameR Documentation

Extract or replace Parts of a Multi-Header Data Frame

Description

The methods to extract parts of a multi-headed data frame. Work the same way as the data.frame. The [<- and [[<- are to be implemented.

Usage

## S3 method for class 'mlth.data.frame'
x[[i]]

## S3 method for class 'mlth.data.frame'
object$name

namesList(x)

selectByList(x, N)

Arguments

x, object

a mlth.data.frame object.

i, j

indices specifying elements to extract. Details in Extract and Extract.data.frame. The list structure can be used to extract or re-arrange a multi-headed data frame, see Details and Examples.

name

a literal character string (use backtick when the name includes spaces or special characters).

N

a list which defines the mlth.data.frame structure to extract. See Details section.

Details

The function namesList returns the list representing the structure of a mlth.data.frame object. The variables are represented by their names (single character string or vector), the sub-tables are represented by named list or character vector (when a sub-table does not include another sub-table. See Examples.

The function selectByList selects the parts of a mlth.data.frame corresponding to the list structure. [[ and [ call selectByList when i is a list.

Examples

L <- mlth(X = c('A', 'B', 'C'),
		       Y = list(N = 1:3, M = 4:6))

L['Y']
L[['Y']]
L$Y ## Same as L[['Y']]
L$Y$M

L[1:2, ] ## Select rows

## Select using a list structure
namesList(L)
L[[list(Y = c('N', 'M', 'N'), 'X')]]
selectByList(L,list(Y=c('N','M','N'),'X')) # Same
L[1:2, list(Y = c('N', 'M', 'N'), 'X')]


IvanVoronin/mlth.data.frame documentation built on Jan. 31, 2024, 10:13 a.m.