Learn R Programming

tern (version 0.9.8)

extract_by_name: 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)

Value

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

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.