Test if the object is a data frame (data.frame, data.table or tibble)
Usage
is_dtx(x, strict = TRUE)
is_dtf(x, strict = TRUE)
is_dtt(x, strict = TRUE)
is_dtbl(x, strict = TRUE)
Arguments
- x
An object
- strict
Should this be strictly the corresponding class
TRUE
, by default, or could it be subclassed too (FALSE
). Withstrict = TRUE
, the grouped_df tibbles and grouped_ts tsibbles are also considered (tibbles or tsibbles wheredplyr::group_by()
was applied).
Value
These functions return TRUE
if the object is of the correct class, otherwise they return FALSE
. is_dtx()
return TRUE
if x
is one of a data.frame, data.table or tibble.
Examples
# data(mtcars)
is_dtf(mtcars) # TRUE
#> [1] TRUE
is_dtx(mtcars) # Also TRUE
#> [1] TRUE
is_dtt(mtcars) # FALSE
#> [1] FALSE
is_dtbl(mtcars) # FALSE
#> [1] FALSE
# but...
is_dtt(as_dtt(mtcars)) # TRUE
#> [1] TRUE
is_dtx(as_dtt(mtcars)) # TRUE
#> [1] TRUE
is_dtbl(as_dtbl(mtcars)) # TRUE
#> [1] TRUE
is_dtx(as_dtbl(mtcars)) # TRUE
#> [1] TRUE
is_dtx(as_dtbl(mtcars) |> dplyr::group_by(cyl)) # TRUE (special case)
#> [1] TRUE
is_dtx("some string") # FALSE
#> [1] FALSE