BBmisc (version 1.13)

names2: 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_)

Value

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

Arguments

x

[ANY]
Object, probably named.

missing.val

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

Examples

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

Run the code above in your browser using DataLab