Create a descriptive statistics table from numeric variables

make_desc_stats_table(
  data,
  columns,
  output = c("min", "median", "mean", "sd", "max", "sum", "NAs"),
  decimals = 2,
  title = NULL,
  subtitle = NULL,
  footnote = NULL
)

Arguments

data

A data.frame with the data you want to make the table from.

columns

A string or vector of strings with the names of the columns you want to use.

output

A string or vector of strings indicating which math functions you want to perform on the columns and present in the table. Options are: 'min', 'median', 'mean', 'sd', 'max', and 'N'. Default is to use all of these math functions. The order you put in these values is the order the table will present the columns.

decimals

A positive integer for how many decimal places you want to round to.

title

A string with the text you want as the title

subtitle

A string with the text you want as the subtitle.

footnote

A string with the text you want as the footnote.

Value

A data.frame with the data that generates the table, which is outputted in the Viewer tab.

Examples

make_desc_stats_table(mtcars, columns = c("mpg", "disp", "wt", "cyl"))
#>   Variable Std. Dev. Median NAs  Max   Mean  Min     Sum
#> 3      Mpg      6.03   19.2   0 33.9  20.09 10.4   642.9
#> 2     Disp    123.94  196.3   0  472 230.72 71.1 7,383.1
#> 4       Wt      0.98   3.33   0 5.42   3.22 1.51  102.95
#> 1      Cyl      1.79      6   0    8   6.19    4     198

make_desc_stats_table(mtcars, c("mpg", "disp", "wt"), output = c("mean", "min"),
decimals = 4, title = "hello", subtitle = "world")
#>   Variable   Min     Mean
#> 2      Mpg  10.4  20.0906
#> 1     Disp  71.1 230.7219
#> 3       Wt 1.513   3.2172