File: scalar.Rd

package info (click to toggle)
r-cran-assertthat 0.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 220 kB
  • sloc: sh: 9; makefile: 2
file content (61 lines) | stat: -rw-r--r-- 1,239 bytes parent folder | download | duplicates (3)
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assertions-scalar.R
\name{scalar}
\alias{is.scalar}
\alias{is.string}
\alias{is.number}
\alias{is.flag}
\alias{is.count}
\title{Assert input is a scalar.}
\usage{
is.scalar(x)

is.string(x)

is.number(x)

is.flag(x)

is.count(x)
}
\arguments{
\item{x}{object to test}
}
\description{
\code{is.scalar} provides a generic method for checking input is a scalar.
\code{is.string}, \code{is.flag}, \code{is.number} and \code{is.count}
provide tests for specific types.
}
\examples{
# 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))

}
\seealso{
Other assertions: \code{\link{are_equal}},
  \code{\link{is.error}}, \code{\link{noNA}},
  \code{\link{not_empty}}
}