Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Produce mock tables #142

Open
asbates opened this issue Oct 4, 2023 · 2 comments
Open

Feature request: Produce mock tables #142

asbates opened this issue Oct 4, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@asbates
Copy link
Collaborator

asbates commented Oct 4, 2023

Description

Be able to generate mock tables where placeholders are used instead of numbers. For example instead of having 1.23 for a mean, we can build a table that has x.xx.

Example Usage

I think an argument to build would be the most natural API.


tplyr_table(adsl, TRT01P, where = SAFFL == "Y") %>% 
  add_layer(
    group_desc(AGE, by = "Age (years)")
  ) %>% 
  add_layer(
    group_count(AGEGR1, by = "Age Categories n (%)")
  ) %>% 
  build(mock = TRUE)

I could see this being problematic though because tplyr_table expects a data frame and the layers use NSE. So maybe there could be a helper function to generate a mock data set. Something like

adsl <- tplyr_mock_data(col_names = c("TRT01P", "SAFFL", "AGE", "AGEGR1"), n_rows = 10)
@asbates asbates changed the title Produce mock tables Feature request: Produce mock tables Oct 4, 2023
@mstackhouse mstackhouse added the enhancement New feature or request label Oct 5, 2023
@mstackhouse
Copy link
Contributor

I like the feature and I think this is doable. I think what we could actually do is create a new function called preview().

Here's how I could envision the process flow:

  • Collect variables declared in the different components of the tplyr_table
  • Assemble a mock dataset with the proper names
  • Allow a parameter where user can specify the treatment groups necessary for display
    • Otherwise mock up fake treatment groups
  • Make a minimal fake dataset based on that info. @asbates this is basically the suggested tplyr_mock_data() function you suggested, but automated based on layer info
    • For counts, mock up some random text values - maybe about 3 distinct values?
    • If it's a nested layer, then 3 distinct outside with 3 distinct inside (total of 9 records)
    • For a desc layer, randomly generate a continuous variable (or just saved a generic numeric vector) to mock the data. Maybe 10 records.
  • Run build on the mock data and get the output
  • Loop over the layers and replace the numeric values with the format string values
    • If auto precision was used, just replace a+n with x + n x's - so "a+2" becomes "xxx"

@asbates any more thoughts?

@asbates
Copy link
Collaborator Author

asbates commented Oct 5, 2023

@mstackhouse One thing I think most people would want is the ability to specify factor levels in addition to treatment groups. If I'm making an AE table for example, I want to see specific values for SOC, not a generic "label 1", "label 2".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants