Skip to content

Instantly share code, notes, and snippets.

@jmbarbone
Last active May 9, 2023 21:16
Show Gist options
  • Save jmbarbone/b3762c76eeb4aff7ca55f4ec3834c3e9 to your computer and use it in GitHub Desktop.
Save jmbarbone/b3762c76eeb4aff7ca55f4ec3834c3e9 to your computer and use it in GitHub Desktop.
do.call(rbind, lapply(
  list(
    integer      = 1L,
    integerish   = 1.0,
    double       = 1.1,
    factor       = factor("a"),
    date_double  = structure(19486, class = "Date"),
    date_integer = structure(19486L, class = "Date"),
    time_double  = structure(1683663687, class = c("POSIXct", "POSIXt")),
    time_integer = structure(1683663687L, class = c("POSIXct", "POSIXt"))
  ),
  function(i) {
    data.frame(
      typeof             = typeof(i),
      is.integer         = is.integer(i),
      is_integer         = rlang::is_integer(i),
      is_integerish      = rlang::is_integerish(i),
      is_bare_integer    = rlang::is_bare_integer(i),
      is_bare_integerish = rlang::is_bare_integerish(i),
      is.numeric         = is.numeric(i),
      is_bare_numeric    = rlang::is_bare_numeric(i)
    )
  }
))
#>               typeof is.integer is_integer is_integerish is_bare_integer is_bare_integerish is.numeric is_bare_numeric
#> integer      integer       TRUE       TRUE          TRUE            TRUE               TRUE       TRUE            TRUE
#> integerish    double      FALSE      FALSE          TRUE           FALSE               TRUE       TRUE            TRUE
#> double        double      FALSE      FALSE         FALSE           FALSE              FALSE       TRUE            TRUE
#> factor       integer      FALSE       TRUE          TRUE           FALSE              FALSE      FALSE           FALSE
#> date_double   double      FALSE      FALSE          TRUE           FALSE              FALSE      FALSE           FALSE
#> date_integer integer       TRUE       TRUE          TRUE           FALSE              FALSE      FALSE           FALSE
#> time_double   double      FALSE      FALSE          TRUE           FALSE              FALSE      FALSE           FALSE
#> time_integer integer       TRUE       TRUE          TRUE           FALSE              FALSE      FALSE           FALSE

Created on 2023-05-09 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment