lget | R Documentation |
Read elements from an lvec
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, ...)
x |
the |
... |
used to pass on additional arguments to other methods. |
index |
a logical or numeric vector to index |
range |
a numeric vector of length 2 specifying a range of elements
to select. Specify either |
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.
Returns an lvec
with the selected elements. In order to convert
the selection to an R-vector as_rvec
can e used.
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.