Description Usage Arguments Examples
Define a new type
1 2 3 4 5 |
check |
A checking function to apply if that type is specified (optional). The function is passed one argument, the value of the object. |
error |
An error function to apply if the check fails. (optional). The function is passed the object name and value in two arguments. |
document |
A character vector that contains the documentation annotation for the type, optional and currently unused. |
machine_type |
A character vector that contains the machine type annotation for the type, optional and currently unused. |
... |
Additional optional fields. |
1 2 3 4 5 6 7 8 9 10 | type.character <- type_define( check = is.character)
type.integer <- type_define( check = is.integer)
prefix <- type_check(function(str = ? character, len = ? integer) {
substring(str, 1, len)
})
## Not run:
prefix(10, 1), # `str` is a `double` not a `character`
prefix("foo", NULL), # `len` is a `NULL` not a `integer`
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.