lget: Read elements from an lvec

View source: R/lget.R

lgetR Documentation

Read elements from an lvec

Description

Read elements from an lvec

Usage

lget(x, ...)

## S3 method for class 'lvec'
lget(x, index = NULL, range = NULL, ...)

## Default S3 method:
lget(x, index = NULL, range = NULL, ...)

## S3 method for class 'data.frame'
lget(x, index = NULL, range = NULL, ...)

Arguments

x

the lvec to read from

...

used to pass on additional arguments to other methods.

index

a logical or numeric vector to index x with

range

a numeric vector of length 2 specifying a range of elements to select. Specify either index or range.

Details

Indexing using index should follow the same rules as indexing a regular R-vector using a logical or numeric index. The range given by range includes both end elements. So, a range of c(1,3) selects the first three elements.

Value

Returns an lvec with the selected elements. In order to convert the selection to an R-vector as_rvec can e used.

Examples

a <- as_lvec(letters[1:4])
# Select first two elements
lget(a, 1:2)
lget(a, c(TRUE, TRUE, FALSE, FALSE))
lget(a, range = c(1,2))

# Logical indices are recycled: select odd elements
lget(a, c(TRUE, FALSE))


lvec documentation built on Nov. 10, 2022, 6:18 p.m.

Related to lget in lvec...