These functions can be used to extract or subset elements of
Rd lists, either bare Rd
containers or Rd_tag
objects.
The [[
operator performs classification of output.
Rd_get_element
acts as [[
but will also accept tags to
search for. The [
operator wraps
Rd_subset
, respectively.
Extract elements from Rd containers
These functions can be used to extract or subset elements of
Rd lists, either bare Rd
containers or Rd_tag
objects.
The [[
operator performs classification of output.
Rd_get_element
acts as [[
but will also accept tags to
search for. The [
operator wraps
Rd_subset
, respectively.
Rd_get_element(x, ..., drop = TRUE)# S3 method for Rd_tag
[[(x, ...)
# S3 method for Rd
[[(x, ...)
Rd_subset(x, i, ..., drop = FALSE)
# S3 method for Rd
[(x, ...)
# S3 method for Rd_tag
[(x, ...)
Either an Rd
or Rd_tag
object.
Must be empty.
For matrices and arrays. If TRUE
the result is
coerced to the lowest possible dimension (see the examples). This
only works for extracting elements, not for the replacement. See
drop
for further details.
indices specifying elements to extract or replace. Indices are
numeric
or character
vectors or empty (missing) or
NULL
. Numeric values are coerced to integer as by
as.integer
(and hence truncated towards zero).
Character vectors will be matched to the names
of the
object (or for matrices/arrays, the dimnames
):
see ‘Character indices’ below for further details.
For [
-indexing only: i
, j
, …
can be
logical vectors, indicating elements/slices to select. Such vectors
are recycled if necessary to match the corresponding extent.
i
, j
, …
can also be negative integers,
indicating elements/slices to leave out of the selection.
When indexing arrays by [
a single argument i
can be a
matrix with as many columns as there are dimensions of x
; the
result is then a vector with elements corresponding to the sets of
indices in each row of i
.
An index value of NULL
is treated as if it were integer(0)
.
Rd_get_element
and [[
:
the return value is not necessarily an Rd.
The class of the element returned will
inferred if it does not have a class.
Lists will be classed as Rd
unless the Rd_tag
attribute
is set in which case a Rd_tag
will be returned
Rd_subset
and [
:
will always return a value of the same class as is given.
Even if what is returned is an empty list, an empty list with
the Rd_tag
attribute set is valid, and denotes a tag without
any content such as the "\item" tag.