Skip to contents

Returns a tidy summary of each variable's structure, missingness, uniqueness, and suitability for use in regression models.

Usage

dissect(data, verbose = FALSE, format = c("flextable", "gt", "tibble"))

Arguments

data

A data frame.

verbose

Logical; if TRUE, print the summary and interpretation notes. The tibble is returned invisibly only when printed by the console.

format

Output format. One of "flextable" (default), "gt", or "tibble". Use format = "tibble" for pipeline-friendly raw output.

Value

A tibble, gt_tbl, or flextable, depending on format. The tibble has columns: Variable, Type, Missing ( Levels, Compatibility, and Hint.

Examples

dissect(data_birthwt, format = "tibble")
#> # A tibble: 10 × 7
#>    Variable Type    `Missing (%)` Unique Levels Compatibility Hint              
#>    <chr>    <chr>   <chr>          <int> <chr>  <chr>         <chr>             
#>  1 low      integer 0%                 2 -      maybe         Two numeric value…
#>  2 age      integer 0%                24 -      compatible    Numeric variable …
#>  3 lwt      integer 0%                75 -      compatible    Numeric variable …
#>  4 race     integer 0%                 3 -      compatible    Numeric variable …
#>  5 smoke    integer 0%                 2 -      maybe         Two numeric value…
#>  6 ptl      integer 0%                 4 -      compatible    Numeric variable …
#>  7 ht       integer 0%                 2 -      maybe         Two numeric value…
#>  8 ui       integer 0%                 2 -      maybe         Two numeric value…
#>  9 ftv      integer 0%                 6 -      compatible    Numeric variable …
#> 10 bwt      integer 0%               131 -      compatible    Numeric variable …
dissect(data_birthwt, format = "gt")
Dataset dissection before regression
Variable Type Missing (%) Unique Levels Compatibility Hint
low integer 0% 2 - maybe Two numeric values; confirm binary coding or convert to factor.
age integer 0% 24 - compatible Numeric variable can be used as continuous.
lwt integer 0% 75 - compatible Numeric variable can be used as continuous.
race integer 0% 3 - compatible Numeric variable can be used as continuous.
smoke integer 0% 2 - maybe Two numeric values; confirm binary coding or convert to factor.
ptl integer 0% 4 - compatible Numeric variable can be used as continuous.
ht integer 0% 2 - maybe Two numeric values; confirm binary coding or convert to factor.
ui integer 0% 2 - maybe Two numeric values; confirm binary coding or convert to factor.
ftv integer 0% 6 - compatible Numeric variable can be used as continuous.
bwt integer 0% 131 - compatible Numeric variable can be used as continuous.
Screening aid only; review coding, missingness, sparse levels, and study context before modeling.
# Print notes that help interpret the data structure dissect(data_birthwt, verbose = TRUE, format = "tibble") #> # A tibble: 10 × 7 #> Variable Type `Missing (%)` Unique Levels Compatibility Hint #> <chr> <chr> <chr> <int> <chr> <chr> <chr> #> 1 low integer 0% 2 - maybe Two numeric value… #> 2 age integer 0% 24 - compatible Numeric variable … #> 3 lwt integer 0% 75 - compatible Numeric variable … #> 4 race integer 0% 3 - compatible Numeric variable … #> 5 smoke integer 0% 2 - maybe Two numeric value… #> 6 ptl integer 0% 4 - compatible Numeric variable … #> 7 ht integer 0% 2 - maybe Two numeric value… #> 8 ui integer 0% 2 - maybe Two numeric value… #> 9 ftv integer 0% 6 - compatible Numeric variable … #> 10 bwt integer 0% 131 - compatible Numeric variable … #> #> Interpretation notes: #> - compatible: ready to use in regression or with minimal preparation #> - maybe: check coding, sparse levels, or whether transformation is needed #> - incompatible: not usable as-is (e.g., all NA or no variation) #> # A tibble: 10 × 7 #> Variable Type `Missing (%)` Unique Levels Compatibility Hint #> <chr> <chr> <chr> <int> <chr> <chr> <chr> #> 1 low integer 0% 2 - maybe Two numeric value… #> 2 age integer 0% 24 - compatible Numeric variable … #> 3 lwt integer 0% 75 - compatible Numeric variable … #> 4 race integer 0% 3 - compatible Numeric variable … #> 5 smoke integer 0% 2 - maybe Two numeric value… #> 6 ptl integer 0% 4 - compatible Numeric variable … #> 7 ht integer 0% 2 - maybe Two numeric value… #> 8 ui integer 0% 2 - maybe Two numeric value… #> 9 ftv integer 0% 6 - compatible Numeric variable … #> 10 bwt integer 0% 131 - compatible Numeric variable …