tt_tbl_dims: Table Transformer: get the dimensions of a table

View source: R/table_transformers.R

tt_tbl_dimsR Documentation

Table Transformer: get the dimensions of a table

Description

With any table object, you can produce a summary table that contains nothing more than the table's dimensions: the number of rows and the number of columns. The output summary table will have two columns and two rows. The first is the ".param." column with the labels "rows" and "columns"; the second column, "value", contains the row and column counts.

Usage

tt_tbl_dims(tbl)

Arguments

tbl

A data table

⁠obj:<tbl_*>⁠ // required

A table object to be used as input for the transformation. This can be a data frame, a tibble, a tbl_dbi object, or a tbl_spark object.

Value

A tibble object.

Examples

Get the dimensions of the game_revenue dataset that is included in the pointblank package.

tt_tbl_dims(tbl = game_revenue)
#> # A tibble: 2 x 2
#>   .param. value
#>   <chr>   <int>
#> 1 rows     2000
#> 2 columns    11

This output table is useful when a table validation depends on its dimensions. Here, we check that game_revenue has at least 1500 rows.

tt_tbl_dims(tbl = game_revenue) %>%
  dplyr::filter(.param. == "rows") %>%
  test_col_vals_gt(
    columns = value,
    value = 1500
  )
#> [1] TRUE

We can check small_table to ensure that number of columns is less than 10.

tt_tbl_dims(tbl = small_table) %>%
  dplyr::filter(.param. == "columns") %>%
  test_col_vals_lt(
    columns = value,
    value = 10
  )
#> [1] TRUE

Function ID

12-3

See Also

Other Table Transformers: get_tt_param(), tt_string_info(), tt_summary_stats(), tt_tbl_colnames(), tt_time_shift(), tt_time_slice()


pointblank documentation built on Oct. 30, 2024, 9:29 a.m.