Table Transformer: obtain a summary stats table for numeric columns
Table Transformer: obtain a summary stats table for numeric columns
With any table object, you can produce a summary table that is scoped to the numeric column values. The output summary table will have a leading column called ".param." with labels for each of the nine rows, each corresponding to the following summary statistics:
Minimum ("min")
5th Percentile ("p05")
1st Quartile ("q_1")
Median ("med")
3rd Quartile ("q_3")
95th Percentile ("p95")
Maximum ("max")
Interquartile Range ("iqr")
Range ("range")
Only numerical data from the input table will generate columns in the output table. Column names from the input will be used in the output, preserving order as well.
tt_summary_stats(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.
Returns
A tibble object.
Examples
Get summary statistics for the game_revenue dataset that is included in the pointblank package.
Table transformers work great in conjunction with validation functions. Let's ensure that the maximum revenue for individual purchases in the game_revenue table is less than $150.
We can get more creative with this transformer. Why not use a transformed
table in a validation plan? While performing validations of the
game_revenue table with an agent we can include the same revenue check as
above by using tt_summary_stats() in the preconditions argument. This
transforms the target table into a summary table for the validation step. The
final step of the transformation in preconditions is a dplyr::filter()
step that isolates the row of the median statistic.
Printing the agent in the console shows the validation report in the
Viewer. Here is an excerpt of validation report. Take note of the final step
(STEP 3) as it shows the entry that corresponds to the col_vals_between()
validation step that uses the summary stats table as its target.
Function ID
12-1
See Also
Other Table Transformers: get_tt_param(), tt_string_info(), tt_tbl_colnames(), tt_tbl_dims(), tt_time_shift(), tt_time_slice()