Skip to contents

Prints column names, summary() statistics, and a sample of rows in clearly labeled sections. Intended for dataset documentation @examples.

Usage

ffp_preview_dataset(
  x,
  name = NULL,
  n_rows = 6L,
  width = getOption("width", 120L)
)

Arguments

x

A data frame.

name

Character label for headings; default is the deparsed name of x.

n_rows

Number of rows to show in the sample display.

width

Print width for the sample rows (options("width")).

Value

Invisibly returns x.

See also

Used across the package vignettes to preview packaged datasets.

Examples

data(tstm_hh_mthspan)
ffp_preview_dataset(tstm_hh_mthspan)
#> 
#> ── tstm_hh_mthspan ─────────────────────────────────────────────────────────────
#> Dimensions: 791 rows × 4 columns(19.8 Kb)
#> 
#> ── Column names (4) ──
#> 
#> • 1. id
#> • 2. month_start
#> • 3. month_end
#> • 4. month_n
#> 
#> ── Summary statistics (all variables) ──
#> 
#>        id        month_start       month_end        month_n     
#>  Min.   :1003   Min.   : 0.000   Min.   :  2.0   Min.   :  3.0  
#>  1st Qu.:3166   1st Qu.: 0.000   1st Qu.:160.0   1st Qu.:161.0  
#>  Median :5412   Median : 0.000   Median :160.0   Median :161.0  
#>  Mean   :5467   Mean   : 5.345   Mean   :146.8   Mean   :142.5  
#>  3rd Qu.:7706   3rd Qu.: 0.000   3rd Qu.:160.0   3rd Qu.:161.0  
#>  Max.   :9996   Max.   :94.000   Max.   :160.0   Max.   :161.0  
#> ── Sample rows (first 6) ──
#> 
#> # A tibble: 6 × 4
#>      id month_start month_end month_n
#>   <int>       <dbl>     <dbl>   <int>
#> 1  1003           0        35      36
#> 2  1015           0         2       3
#> 3  1031           0       160     161
#> 4  1046           0       160     161
#> 5  1059           0       160     161
#> 6  1078           0       160     161