
Last chance! 50% off unlimited learning
Sale ends in
checkArg(x, cl, s4 = FALSE, len, min.len, max.len,
choices, subset, lower = NA, upper = NA, na.ok = TRUE,
formals)
character
]
Class that argument must
x
must s4
.logical(1)
]
If TRUE
, use
is
for checking class cl
, otherwise use
inherits
, which implies that only S3
classes are correctly checked. This is done integer(1)
]
Length that argument
must have. Not checked if not passed, which is the
default.integer(1)
]
Minimal length that
argument must have. Not checked if not passed, which is
the default.integer(1)
]
Maximal length that
argument must have. Not checked if not passed, which is
the default.numeric(1)
]
Lower bound for
numeric vector arguments. Default is NA
, which
means not required.numeric(1)
]
Upper bound for
numeric vector arguments. Default is NA
, which
means not required.logical(1)
]
Is it ok if a vector
argument contains NAs? Default is TRUE
.character
]
Is it ok if a vector
argument contains NAs? Default is TRUE
.x <- 1L
checkArg(x, "integer", len=1, na.ok=FALSE, upper=3L)
x <- as.integer(NA)
checkArg(x, "integer", len=1, na.ok=TRUE)
x <- c("foo", "bar")
checkArg(x, "character")
x <- "foo"
checkArg(x, choices=c("foo", "bar"))
x <- c("foo", "bar")
checkArg(x, subset=c("foo", "bar"))
fun <- function(foo, bar)
checkArg(fun, formals=c("foo", "bar"))
Run the code above in your browser using DataLab