names2: Replacement for names which always returns a vector.

View source: R/names2.R

names2R Documentation

Replacement for names which always returns a vector.

Description

A simple wrapper for names. Returns a vector even if no names attribute is set. Values NA and "" are treated as missing and replaced with the value provided in missing.val.

Usage

names2(x, missing.val = NA_character_)

Arguments

x

[ANY]
Object, probably named.

missing.val

[ANY]
Value to set for missing names. Default is NA_character_.

Value

[character]: vector of the same length as x.

Examples

x = 1:3
names(x)
names2(x)
names(x[1:2]) = letters[1:2]
names(x)
names2(x)

BBmisc documentation built on Sept. 29, 2022, 5:12 p.m.

Related to names2 in BBmisc...