GEMINI-Medicine / Rgemini

A custom R package that provides a variety of functions to perform data analyses with GEMINI data
https://gemini-medicine.github.io/Rgemini/
Other
3 stars 0 forks source link

67 bigmark table1 #117

Closed loffleraSMH closed 4 months ago

loffleraSMH commented 4 months ago

Closes #67

I’ve implemented some enhancement for each render function to allow for additional user inputs that are passed to prettyNum, which enables additional formatting that can be useful when presenting large numbers (e.g., big.mark = “,” to add comma thousands separator). I’ve tested all render functions to check if the updated code produces the expected output (see screenshot below) and made sure that nothing breaks.

I also added a small bug fix for digits to be applied consistently to all outputs, including % missing.

The person reviewing the changes should perform some additional testing. The following code can be used as a starting point (you can comment/uncomment the different render functions to test each function's behavior):

set.seed(3)
gender <- c(sample(c("M", "F"), size = 99995, replace = TRUE), rep(NA, times = 5))
exposure <- sample(
  c("pre-pandemic", "pandemic", "post-pandemic"), 
  size = 100000, replace = TRUE
)
income <- c(rnorm(90000, mean = 70000, sd = 5000), rep(NA, times = 10000))
condition <- sample(
  c("DVT", "CVD", "DM", "Pneumonia", "Dementia", NA), 
  size = 100000, replace = TRUE, prob = c(0.01, 0.20, 0.4, 0.35, 0.05, .01)
)
data <- data.frame(gender = gender, exposure = exposure, income = income, condition = condition)

table1(
  ~ gender + income + condition | exposure, 
  data = data, 
  render = render_cell_suppression.default, 
  digits = 2,
  big.mark = ",",
  #render.categorical = render_cell_suppression.categorical, # or: render_strict_cell_suppression.categorical,
  #render.continuous = render_cell_suppression.continuous
  #render.missing = render_cell_suppression.missing
  render.strat = render_cell_suppression.strat
)

Screenshot 2024-05-14 153132