File: checkNamed.Rd

package info (click to toggle)
r-cran-checkmate 2.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,504 kB
  • sloc: ansic: 2,196; sh: 9; makefile: 8
file content (80 lines) | stat: -rw-r--r-- 2,309 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkNamed.R
\name{checkNamed}
\alias{checkNamed}
\alias{check_named}
\alias{assertNamed}
\alias{assert_named}
\alias{testNamed}
\alias{test_named}
\title{Check if an argument is named}
\usage{
checkNamed(x, type = "named")

check_named(x, type = "named")

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

assert_named(x, type = "named", .var.name = vname(x), add = NULL)

testNamed(x, type = "named")

test_named(x, type = "named")
}
\arguments{
\item{x}{[any]\cr
Object to check.}

\item{type}{[character(1)]\cr
Select the check(s) to perform.
\dQuote{unnamed} checks \code{x} to be unnamed.
\dQuote{named} (default) checks \code{x} to be named which excludes names to be \code{NA} or empty (\code{""}).
\dQuote{unique} additionally tests for non-duplicated names.
\dQuote{strict} checks for unique names which comply to R's variable name restrictions.
Note that for zero-length \code{x} every name check evaluates to \code{TRUE}.}

\item{.var.name}{[\code{character(1)}]\cr
Name of the checked object to print in assertions. Defaults to
the heuristic implemented in \code{\link{vname}}.}

\item{add}{[\code{AssertCollection}]\cr
Collection to store assertion messages. See \code{\link{AssertCollection}}.}
}
\value{
Depending on the function prefix:
 If the check is successful, the functions 
 \code{assertNamed}/\code{assert_named} return 
 \code{x} invisibly, whereas
 \code{checkNamed}/\code{check_named} and 
 \code{testNamed}/\code{test_named} return 
 \code{TRUE}.
 If the check is not successful, 
 \code{assertNamed}/\code{assert_named}
 throws an error message, 
 \code{testNamed}/\code{test_named}
 returns \code{FALSE},
 and \code{checkNamed}/\code{check_named} 
 return a string with the error message.
 The function \code{expect_named} always returns an
 \code{\link[testthat]{expectation}}.
}
\description{
Check if an argument is named
}
\note{
These function are deprecated and will be removed in a future version.
Please use \code{\link{checkNames}} instead.
}
\examples{
x = 1:3
testNamed(x, "unnamed")
names(x) = letters[1:3]
testNamed(x, "unique")
}
\seealso{
Other attributes: 
\code{\link{checkClass}()},
\code{\link{checkMultiClass}()},
\code{\link{checkNames}()}
}
\concept{attributes}