This function prepares a data table for displaying by providing user-friendly names, removing unneeded variables, and formatting percentages.

prep_table(
  y,
  df,
  df_summarized,
  id,
  y_right = NULL,
  facet_var = rlang::sym("VIS_Groep"),
  facet_name_var = rlang::sym("VIS_Groep_naam"),
  table_type = c("basic", "advanced"),
  rownames = FALSE,
  extensions = c("Buttons"),
  options_DT = basic_options(),
  limit_width = "values",
  ...
)

Arguments

y

A string specifying the column name to be used as the y-axis variable.

df

A data frame containing the raw data.

df_summarized

A data frame containing the summarized data.

id

A string specifying the ID associated with the data.

y_right

An optional string specifying the column name to be used as the second y-axis variable. Default is NULL.

facet_var

A symbol specifying the column to be used for faceting. Default is 'VIS_Groep'.

facet_name_var

A symbol specifying the column to be used for faceting names. Default is 'VIS_Groep_naam'.

table_type

Choose from basic for a simple datatable and advanced for more buttons etc.

rownames

A logical value indicating whether to display row names.

extensions

A character vector specifying the DataTables extensions to be used.

options_DT

A list of DataTables options.

limit_width

A character string indicating how to limit column width.

...

Further arguments passed on to the 'make_basic_table' function.

Value

A DT::datatable object ready for displaying.

Examples

df <- data.frame(VIS_Groep = c("Group1", "Group1", "Group2", "Group2"),
                VIS_Groep_naam = c("Name1", "Name1", "Name2", "Name2"),
                y = c(TRUE, TRUE, FALSE, FALSE), z = c(TRUE, FALSE, TRUE, FALSE))
df_summarized <- df %>%
 dplyr::group_by(VIS_Groep, VIS_Groep_naam) %>%
 dplyr::summarise(
   y = mean(y),
   z = mean(z)
 ) %>%
 dplyr::ungroup()
#> `summarise()` has grouped output by 'VIS_Groep'. You can override using the
#> `.groups` argument.
 id <- "id"
output <- prep_table("y", df, df_summarized, id = id)