extract_by_name: Extract elements by name

View source: R/utils.R

extract_by_nameR Documentation

Extract elements by name

Description

This utility function extracts elements from a vector x by names. Differences to the standard [ function are:

Usage

extract_by_name(x, names)

Arguments

x

(named vector)
where to extract named elements from.

names

(character)
vector of names to extract.

Details

  • If x is NULL, then still always NULL is returned (same as in base function).

  • If x is not NULL, then the intersection of its names is made with names and those elements are returned. That is, names which don't appear in x are not returned as NAs.

Value

NULL if x is NULL, otherwise the extracted elements from x.


tern documentation built on Sept. 24, 2024, 9:06 a.m.