tidytable1 produces a tidy data frame that contains the common information included in Table 1 of academic papers for an input data frame. Inspired by [tableone](https://cran.r-project.org/web/packages/tableone/), tidytable1 uses the tidyverse functions for easy customization.

tidytable1(input_df, info_cols = list(), calc_cols = list(`#missing` =
  function(x) sum(is.na(x))), num_cols = list(mean = mean, sd = sd),
  custom_vars = c(), custom_cols = list(), col_order = c(),
  row_order = list(), digits = 2, add_cat_header_row = TRUE)

Arguments

input_df

A data_frame for which table1 (the descriptive stats) is produced.

info_cols

A list that will be used for informational columns in table1, for example, the label (description) and data source of variables. The names of the list will be used as column names in table1, while the names of value vector will be matched to column names in input_df.

calc_cols

A list of table1 columns to be calculated from functions.

num_cols

A list of table1 columns to be calculated from functions for numeric variables.

custom_vars

A vector of input_df columns for which custom_cols will be added.

custom_cols

A list of table1 columns to be calculated from functions for custom variables (custom_vars).

col_order

A vector according to which table1 columns will be ordered.

row_order

A list according to which table1 rows (variables in input_df) will be ordered.

digits

Number of digits for stats in table1 (Default 2).

add_cat_header_row

Whether to add a header row for categorical variable (Default TRUE).

Value

A data frame containing the descriptive stats, by default containing mean and sd for numeric variables, Category, frequency, and `