View source: R/helper-functions.R
to_integer | R Documentation |
R does not have a built-in function to determine if a value is an integer
(is.integer
will check if the class of an object is "integer", but
is.integer(3)
will return FALSE). This helper function fills that gap. It
will attempt to convert the input to an integer, but will error on any input
that cannot be confidently expressed as an integer. It serves as a stricter
version of as.integer
. For example, the function will convert 3
or "3"
to integers, but will error on 3.5
or "three"
.
to_integer(x)
x |
An input of any type. |
An integer interpretation of x
, if possible.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.