is_integer_like: Check if an object looks like an integer

Description Usage Arguments Value Examples

View source: R/is_integer_like.R

Description

Take a vector and check to see if it looks like it contains only integers.

Usage

1

Arguments

x

a vector of values to check

Value

TRUE or FALSE indicating if all values look like integers - if the vector is not of type character or numeric it will always return FALSE

Examples

1
2
3
4
5
6
7
8
9
library(dplyr)
data <-
  tibble(
    x = c(1, 2, 3),
    y = c("4", "5", "6"),
    z = c("a", "b", "c")
  )
data %>%
  mutate(across(where(is_integer_like), as.integer))

Moohan/hscfunctions documentation built on Dec. 17, 2021, 4:20 a.m.