Learn R Programming

rlang (version 0.1)

has_name: Does an object have an element with this name?

Description

This function returns a logical value that indicates if a data frame or another named object contains an element with a specific name.

Usage

has_name(x, name)

Arguments

x

A data frame or another named object

name

Element name(s) to check

Value

A logical vector of the same length as name

Details

Unnamed objects are treated as if all names are empty strings. NA input gives FALSE as output.

Examples

Run this code
# NOT RUN {
has_name(iris, "Species")
has_name(mtcars, "gears")
# }

Run the code above in your browser using DataLab