/
checkDataFrame.R
50 lines (44 loc) · 1.57 KB
/
checkDataFrame.R
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
#' Check if an argument is a data frame
#'
#' @templateVar fn DataFrame
#' @template x
#' @param all.missing [\code{logical(1)}]\cr
#' Are columns with only missing values allowed? Default is \code{TRUE}.
#' @inheritParams checkMatrix
#' @inheritParams checkList
#' @template null.ok
#' @template checker
#' @family compound
#' @family basetypes
#' @export
#' @useDynLib checkmate c_check_dataframe
#' @examples
#' testDataFrame(iris)
#' testDataFrame(iris, types = c("numeric", "factor"), min.rows = 1, col.names = "named")
checkDataFrame = function(x, types = character(0L), any.missing = TRUE, all.missing = TRUE, min.rows = NULL, max.rows = NULL, min.cols = NULL, max.cols = NULL, nrows = NULL, ncols = NULL, row.names = NULL, col.names = NULL, null.ok = FALSE) {
.Call(c_check_dataframe, x, any.missing, all.missing, min.rows, max.rows, min.cols, max.cols, nrows, ncols, row.names, col.names, null.ok) %and%
checkListTypes(x, types)
}
#' @export
#' @rdname checkDataFrame
check_data_frame = checkDataFrame
#' @export
#' @include makeAssertion.R
#' @template assert
#' @rdname checkDataFrame
assertDataFrame = makeAssertionFunction(checkDataFrame, use.namespace = FALSE)
#' @export
#' @rdname checkDataFrame
assert_data_frame = assertDataFrame
#' @export
#' @include makeTest.R
#' @rdname checkDataFrame
testDataFrame = makeTestFunction(checkDataFrame)
#' @export
#' @rdname checkDataFrame
test_data_frame = testDataFrame
#' @export
#' @include makeExpectation.R
#' @template expect
#' @rdname checkDataFrame
expect_data_frame = makeExpectationFunction(checkDataFrame, use.namespace = FALSE)