File: checkNumeric.R

package info (click to toggle)
r-cran-checkmate 2.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,512 kB
  • sloc: ansic: 2,211; sh: 9; makefile: 8
file content (56 lines) | stat: -rw-r--r-- 1,901 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
#' Check that an argument is a vector of type numeric
#'
#' @description
#' Vectors of storage type \dQuote{integer} and \dQuote{double} count as \dQuote{numeric}, c.f. \code{\link[base]{is.numeric}}.
#' To explicitly check for real integer or double vectors, see \code{\link{checkInteger}}, \code{\link{checkIntegerish}} or
#' \code{\link{checkDouble}}.
#'
#' @templateVar fn Numeric
#' @template x
#' @template na-handling
#' @inheritParams checkVector
#' @template bounds
#' @template sorted
#' @param finite [\code{logical(1)}]\cr
#'  Check for only finite values? Default is \code{FALSE}.
#' @template typed.missing
#' @template null.ok
#' @template checker
#' @family basetypes
#' @useDynLib checkmate c_check_numeric
#' @export
#' @examples
#' testNumeric(1)
#' testNumeric(1, min.len = 1, lower = 0)
checkNumeric = function(x, lower = -Inf, upper = Inf, finite = FALSE, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, sorted = FALSE, names = NULL, typed.missing = FALSE, null.ok = FALSE) {
  .Call(c_check_numeric, x, lower, upper, finite, any.missing, all.missing, len, min.len, max.len, unique, sorted, names, typed.missing, null.ok)
}

#' @export
#' @rdname checkNumeric
check_numeric = checkNumeric

#' @export
#' @include makeAssertion.R
#' @template assert
#' @rdname checkNumeric
assertNumeric = makeAssertionFunction(checkNumeric, c.fun = "c_check_numeric", use.namespace = FALSE)

#' @export
#' @rdname checkNumeric
assert_numeric = assertNumeric

#' @export
#' @include makeTest.R
#' @rdname checkNumeric
testNumeric = makeTestFunction(checkNumeric, c.fun = "c_check_numeric")

#' @export
#' @rdname checkNumeric
test_numeric = testNumeric

#' @export
#' @include makeExpectation.R
#' @template expect
#' @rdname checkNumeric
expect_numeric = makeExpectationFunction(checkNumeric, c.fun = "c_check_numeric", use.namespace = FALSE)