scalar: Assert input is a scalar.

Description Usage Arguments See Also Examples

Description

is.scalar provides a generic method for checking input is a scalar. is.string, is.flag, is.number and is.count provide tests for specific types.

Usage

1
2
3
4
5
6
7
8
9

Arguments

x

object to test

See Also

Other assertions: are_equal, is.error, noNA, not_empty

Examples

 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
# Generic check for scalars
see_if(is.scalar("a"))
see_if(is.scalar(1:10))

# string = scalar character vector
see_if(is.string(1:3))
see_if(is.string(c("a", "b")))
see_if(is.string("x"))

# number = scalar numeric/integer vector
see_if(is.number(1:3))
see_if(is.number(1.5))

# flag = scalar logical vector
see_if(is.flag(1:3))
see_if(is.flag("a"))
see_if(is.flag(c(FALSE, FALSE, TRUE)))
see_if(is.flag(FALSE))

# count = scalar positive integer
see_if(is.count("a"))
see_if(is.count(-1))
see_if(is.count(1:5))
see_if(is.count(1.5))
see_if(is.count(1))

assertthat documentation built on May 1, 2019, 10:25 p.m.