as_any_integer {fabR} | R Documentation |
Create objects of type "integer".
Description
Create or test for objects of type "integer".
This function is a wrapper of the function as.integer()
and evaluates
if the object to be coerced can be interpreted as a integer. Any object :
NA, NA_integer, NA_Date_, (...),
Boolean, such as 0, 0L, F, FALSE, false, FaLsE, (...),
Any string "1", "+1", "-1", "1.0000"
will be converted as NA or integer. Any other other will return an
error.
Usage
as_any_integer(x)
Arguments
x |
Object to be coerced or tested. Can be a vector. |
Value
An integer object of the same size.
See Also
Examples
{
library(dplyr)
as_any_integer("1")
as_any_integer(c("1.000","2.0","1","+12","-12"))
try(as_any_integer('foo'))
tibble(values = c("1.000","2.0","1","+12","-12")) %>%
mutate(bool_values = as_any_integer(values))
}
[Package fabR version 2.1.0 Index]