Learn R Programming

container (version 1.0.5)

OpsExtract: Extract Parts of a Container Object

Description

Extract parts of a Container object similar to R's base extract operators on lists.

Usage

# S3 method for Container
[(x, ...)

# S3 method for Container [[(x, i)

Arguments

x

Container object from which to extract elements.

i, ...

indices specifying elements to extract. Indices are numeric or character vectors or a list containing both.

Details

[ selects multiple values. The indices can be numeric or character or both. They can be passed as a vector or list or, for convenience, just as a comma-separated sequence (see Examples). Non-existing indices are ignored.

[[ selects a single value using a numeric or character index.

Examples

Run this code
co = container(a = 1, b = 2, c = 3, d = 4)
co[1:2]
co[1, 4]
co["d", 2]
co[list("d", 2)]
co[0:10]

co = container(a = 1, b = 2)
co[[1]]
co[["a"]]
co[["x"]]

Run the code above in your browser using DataLab