Skip to contents

The get_tt_param() function can help you to obtain a single parameter value from a summary table generated by the tt_*() functions tt_summary_stats(), tt_string_info(), tt_tbl_dims(), or tt_tbl_colnames(). The following parameters are to be used depending on the input tbl:

The tt_summary_stats() and tt_string_info() functions will generate summary tables with columns that mirror the numeric and character columns in their input tables, respectively. For that reason, a column name must be supplied to the column argument in get_tt_param().

Usage

get_tt_param(tbl, param, column = NULL)

Arguments

tbl

A summary table generated by either of the tt_summary_stats(), tt_string_info(), tt_tbl_dims(), or tt_tbl_colnames() functions.

param

The parameter name associated to the value that is to be gotten. These parameter names are always available in the first column (.param.) of a summary table obtained by tt_summary_stats(), tt_string_info(), tt_tbl_dims(), or tt_tbl_colnames().

column

The column in the summary table for which the data value should be obtained. This must be supplied for summary tables generated by tt_summary_stats() and tt_string_info() (the tt_tbl_dims() and tt_tbl_colnames() functions will always generate a two-column summary table).

Examples

Get summary statistics for the first quarter of the game_revenue dataset that's included in the pointblank package.

stats_tbl <- 
  game_revenue %>%
  tt_time_slice(slice_point = 0.25) %>%
  tt_summary_stats()
  
stats_tbl

## # A tibble: 9 × 3
##   .param. item_revenue session_duration
##   <chr>          <dbl>            <dbl>
## 1 min             0.02              5.1
## 2 p05             0.03             11  
## 3 q_1             0.08             17.2
## 4 med             0.28             28.3
## 5 q_3             1.37             32  
## 6 p95            40.0              37.1
## 7 max           143.               41  
## 8 iqr             1.28             14.8
## 9 range         143.               35.9

Sometimes you need a single value from the table generated by the tt_summary_stats() function. For that, we can use the get_tt_param() function. So if we wanted to test whether the maximum session duration during the rest of the time period (the remaining 0.75) is never higher than that of the first quarter of the year, we can supply a value from stats_tbl to test_col_vals_lte():

game_revenue %>%
  tt_time_slice(
    slice_point = 0.25,
    keep = "right"
  ) %>%
  test_col_vals_lte(
    columns = vars(session_duration), 
    value = get_tt_param(
      tbl = stats_tbl,
      param = "max",
      column = "session_duration"
    )
  )

## [1] TRUE

Function ID

12-7

See also