The is_shrthnd_*
family of functions test whether a vector is either a
shrthnd_num()
, or a shrthnd_list()
. is_shrthnd_integer()
and
is_shrthnd_double()
test whether an object is a shrthnd_num()
vector
and whether the underlying data type is an integer()
or a double()
.
is_shrthnd_tbl()
test whether an object is a shrthnd_tbl()
tibble.
Usage
is_shrthnd_num(x)
is_shrthnd_integer(x)
is_shrthnd_double(x)
is_numeric(x)
is_shrthnd_list(x)
is_shrthnd_tbl(x)
Details
In keeping with base R practice around complex numeric objects such as
Date()
, difftime()
and POSIXct()
, using is.numeric()
on a
shrthnd_num()
vector will return FALSE. The is_numeric()
function
included in {shrthnd}
will return TRUE if a vector is either a standard
numeric vector or is a shrthnd_num()
.
See also
as_shrthnd()
,
make_shrthnd_num()
,
shrthnd_coercion
,
shrthnd_maths
,
shrthnd_num()
,
shrthnd_tags()
,
tag_match()
Examples
x <- c("12", "34.567", "[c]", "NA", "56.78[e]", "78.9", "90.123[e]")
sh_x <- shrthnd_num(x, c("[c]", "[e]"))
is_shrthnd_num(sh_x)
#> [1] TRUE
is_shrthnd_double(sh_x)
#> [1] TRUE
y <- c("12", "34", "[c]", "NA", "56[e]", "78", "90[e]")
sh_y <- shrthnd_num(y, c("[c]", "[e]"))
is_shrthnd_num(sh_y)
#> [1] TRUE
is_shrthnd_integer(sh_y)
#> [1] TRUE
z <- 1:10
is.numeric(x)
#> [1] FALSE
is.numeric(z)
#> [1] TRUE
is_numeric(x)
#> [1] FALSE
is_numeric(z)
#> [1] TRUE
sh_l <- shrthnd_list(sh_x)
is_shrthnd_list(sh_l)
#> [1] TRUE
tbl <- tibble::tibble(x = x, sh_x = sh_x)
sh_tbl <- shrthnd_tbl(tbl, title = "Example table")
is_shrthnd_tbl(sh_tbl)
#> [1] TRUE