Type predicates

Share:

Description

These type predicates aim to make type testing in R more consistent. They are wrappers around typeof, so operate at a level beneath S3/S4 etc.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19

Arguments

x

object to be tested.

Details

Compare to base R functions:

  • Unlike is.atomic(), is_atomic() does not return TRUE for NULL.

  • Unlike is.vector(), is_vector() test if an object is an atomic vector or a list. is.vector checks for the presence of attributes (other than name).

  • is_numeric() is not generic so, (e.g.) dates and date times are TRUE, not FALSE.

  • is_function() returns TRUE only for regular functions, not special or primitive functions.

See Also

bare-type-predicates scalar-type-predicates

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.