insightsengineering / cards

CDISC Analysis Results Data
https://insightsengineering.github.io/cards/
24 stars 0 forks source link

Should we add `ard_stack(strata)` argument? #214

Closed ddsjoberg closed 3 months ago

ddsjoberg commented 3 months ago

This would be similar to the by argument. In AE tables, we often need to calculate rates within SOC/TERM and overall, and this could be helpful?

I can see a scenario where one may want to use both by and strata, and they only want overall results across by (not strata). Maybe the overall argument could be updated from a logical to overall = c("by", "strata") where the values would be columns to calculate over during the overall calculation. 🤔

ddsjoberg commented 3 months ago

one more thought....we often want to perform the same calculations stratified by SOC and again by SOC/AE. Is there an easy way we can make this happen in this function? Maybe a new arguments like overall_by, overall_strata, over_all_strata? I mean, I don't love all these new args...but just thinking

ddsjoberg commented 3 months ago

another thought: iterating through strata argument actually won't work for AE tables, because the AE term data frame is different from the SOC data frame, which is different from the overall data frame (typically the first will be one row per subject per SOC per AE term, the next will be one row per subject per SOC, the next one line per subject)

ddsjoberg commented 3 months ago

Ideal solution would:

  1. Have an optional check in ard_heirarchical() to specify the subject ID and we can print a warning if we see duplicates when rates are being returned.
  2. Would be lovely to have the functionality to concisely perform tabulations by AE term, then SOC, then overall. Not sure if this can done within ard_stack(). Maybe we need a new function like ard_stack_heirarchical() with more directed arguments for this calculation.
  3. The above function should also have the ability to tabulate overall (without a strata argument) which is currently not possible in ard_heirarchical().
ddsjoberg commented 3 months ago

We agree that the first item is a go!

Numbers 2 and 3....not for now.