predicates-type: Type predicates

Description Usage Arguments See Also Examples

Description

Type predicates

Usage

 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

Arguments

x

Object to test.

n

Length.

encoding

Encoding of a string or character vector. One of UTF-8, latin1, or unknown.

finite

Whether values must be finite. Examples of non-finite values are Inf, -Inf and NaN.

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
f <- function(x, y, z) NULL

## Require all arguments to be integer (vectors)
foo <- firmly(f, chk_integer())
foo(0L, 1:2, length(letters))
## Not run: 
foo(0L, c(1, 2), length(letters))
## End(Not run)

## Require all arguments to be scalar integers
bar <- firmly(f, chk_integer(n = 1))
bar(0L, 1L, length(NA))
## Not run: 
bar(0L, 1L, lengths(letters))
## End(Not run)

## Require x, y to be character (vectors), and z to be an length-1 list
baz <- firmly(f, chk_character(x, y), chk_list(n = 1, z))
baz(letters, "text", list(1))
## Not run: 
baz(0, "text", list(1, 2))
## End(Not run)

egnha/rong documentation built on May 7, 2019, 9:48 p.m.