as_any_integer | R Documentation |
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.
as_any_integer(x)
x |
Object to be coerced or tested. Can be a vector. |
An integer object of the same size.
as.logical()
{
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))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.