Skip to content

Creating multiple one or n-way tables #36

@mbcann01

Description

@mbcann01

Currently using purr::map_df. Here is an example from L2C quarterly report:

# Loop over all categorical vars
cat_stats <- purrr::map_df(
  quos(gender_f, race_3cat_f, hispanic_f), 
  function(x) {
    demographics %>%
      filter(screened_in == 1) %>% 
      freq_table({{x}}) %>%
      freq_format(recipe = "n (percent)", digits = 1) %>%
      select(var, cat, formatted_stats) %>%
      # Add a row with the var name only
      add_row(var = quo_name(x), .before = 1) %>% 
      # Add blank row below
      add_row(var = "", cat = "", formatted_stats = "")
  }
)

I should either:

  1. Create a wrapper function to make this easier to read.
  2. Document using purrr::map_df really well.
  3. Both.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Develop Next

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions