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]: Occurrences calculation #1316

Closed
3 tasks done
pzhang-cims opened this issue Sep 29, 2024 · 1 comment
Closed
3 tasks done

[Feature Request]: Occurrences calculation #1316

pzhang-cims opened this issue Sep 29, 2024 · 1 comment

Comments

@pzhang-cims
Copy link

pzhang-cims commented Sep 29, 2024

Feature description

Hi there,

Thanks for the effort on {tern} package development! I would like to check with you, if there a way to generate an occurrence table with the shell like below? The occurrence (take AE table as example) and percentage are shown as the same row as the SOC level.

image

I know that there is a way to generate the number by split_rows_by() and then summarize_num_patients(). However, this way only generate the n() into another line.

Also, i notice there is a function called summarize_row_groups() to add split_rows_by, however, this can only count non-unique number, instead of unique numbers. So even with customize cfun, this cannot achieve the goal.

Can we have a way to generate the results like above in screenshot?

Thanks in advance.

Best,

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
@pzhang-cims
Copy link
Author

Sry just happen to find out that we can implement like below with child_labels='hidden'


lyt <- basic_table() %>%
  split_cols_by(var= 'ARM')%>%
  ###to specify if total colum is needed, label and be set
  add_overall_col('Total')%>%
  ###add colcounts for all.
  add_colcounts()%>%
  split_rows_by(
    "AESOC",
    child_labels = "hidden"

  ) %>%
  ### you just need a variable here, 
  count_occurrences(
    vars = c("AESOC"),
    .indent_mods =0
  ) %>%
  count_occurrences(
    vars = c("AEDECOD"),
    .indent_mods =1
  ) 
  
###for alt_counts_df, make sure they have the same colum variable name
build_table(lyt,random.cdisc.data::cadae,alt_counts_df = random.cdisc.data::cadsl)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant