Learn R Programming

checkmate (version 1.0)

checkNamed: Check if an argument is named

Description

Check if an argument is named

Usage

checkNamed(x, type = "named")

assertNamed(x, type = "named", .var.name)

testNamed(x, type = "named")

Arguments

x
[ANY] Object to check.
.var.name
[character(1)] Name for x. Defaults to a heuristic to determine the name using deparse and substitute.
type
[character(1)] Select the check(s) to perform. unnamed checks x to be unnamed. named (default) checks x to be named, this includes names to be not NA or emtpy ("").

Value

  • Depending on the function prefix: If the check is successful, all functions return TRUE. If the check is not successful, assertNamed throws an error message, testNamed returns FALSE and checkNamed returns a string with the error message.

Examples

Run this code
x = 1:3
 testNamed(x, "unnamed")
 names(x) = letters[1:3]
 testNamed(x, "unique")

Run the code above in your browser using DataLab