R/is_dtx.R
is_dtx.Rd
Test if the object is a data frame (data.trame, data.frame, data.table or tibble)
is_dtx(x, strict = TRUE)
is_dtrm(x, strict = TRUE)
is_dtf(x, strict = TRUE)
is_dtt(x, strict = TRUE)
is_dtbl(x, strict = TRUE)
An object
Should this be strictly the corresponding class TRUE
, by default, or could it be subclassed too (FALSE
). With strict = TRUE
, the grouped_df tibbles and grouped_ts tsibbles are also considered (tibbles or tsibbles where dplyr::group_by()
was applied).
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, tibble, or data.trame.
# 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
is_dtrm(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_dtrm(as_dtrm(mtcars)) # TRUE
#> [1] TRUE
is_dtx(as_dtrm(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