In the base R we have the function summary, but the output is no by default
a data.frame
, so pdf1_summary
is an enhancement of this function
to summarize data frames.
Arguments
- obj
Object used to create the table.
data.frame
,list
or environment (or object coercible byas.data.frame
to adata.frame
)- na_rm
option to remove
NA
from variables
Examples
mtcars |>
mypdf1::pdf1_summary()
#> # A tibble: 11 × 7
#> variable mean median sd min max na_count
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 mpg 20.1 19.2 6.03 10.4 33.9 0
#> 2 cyl 6.19 6 1.79 4 8 0
#> 3 disp 231. 196. 124. 71.1 472 0
#> 4 hp 147. 123 68.6 52 335 0
#> 5 drat 3.60 3.70 0.535 2.76 4.93 0
#> 6 wt 3.22 3.32 0.978 1.51 5.42 0
#> 7 qsec 17.8 17.7 1.79 14.5 22.9 0
#> 8 vs 0.438 0 0.504 0 1 0
#> 9 am 0.406 0 0.499 0 1 0
#> 10 gear 3.69 4 0.738 3 5 0
#> 11 carb 2.81 2 1.62 1 8 0
airquality |> mypdf1::pdf1_summary(na_rm = FALSE)
#> # A tibble: 6 × 7
#> variable mean median sd min max na_count
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Ozone NA NA NA NA NA 37
#> 2 Solar.R NA NA NA NA NA 7
#> 3 Wind 9.96 9.7 3.52 1.7 20.7 0
#> 4 Temp 77.9 79 9.46 56 97 0
#> 5 Month 6.99 7 1.42 5 9 0
#> 6 Day 15.8 16 8.86 1 31 0
iris |> mypdf1::pdf1_summary()
#> Warning: string and factors variables were removed for calculations
#> # A tibble: 4 × 7
#> variable mean median sd min max na_count
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Sepal.Length 5.84 5.8 0.828 4.3 7.9 0
#> 2 Sepal.Width 3.06 3 0.436 2 4.4 0
#> 3 Petal.Length 3.76 4.35 1.76 1 6.9 0
#> 4 Petal.Width 1.20 1.3 0.762 0.1 2.5 0