check_length | R Documentation |
This function checks that the length of an input to a parent function is correct. If not, the function returns a helpful error message.
check_length(
arg = deparse(substitute(input)),
input,
req_length,
req_arg = deparse(substitute(req_length))
)
arg |
(optional) A character string which defines the argument of a parent function. |
input |
An object. |
req_length |
A number which defines the required length of |
req_arg |
A character which defines the name of the object which defines the required length. |
The function returns a helpful error message for unnamed lists (ignoring empty lists if requested) or the inputted list unchanged.
Edward Lavender
## Not run:
x <- data.frame(x = 1, y = 1)
labels = 1:10
check_length(arg = "labels",
input = labels,
req_length = length(colnames(x)),
req_arg = "colnames(x)"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.