tern
tern copied to clipboard
split_cols_by only allows variables from alt_counts_df argument
For my recent Ophthalmology studies, we got table requests like blow

For these tables, the nested columns are from variables in analysis dataset instead of the alt_counts_df dataset. For sample codes
adsl <- synthetic_cdisc_data("latest")$adsl
adcm <- synthetic_cdisc_data("latest")$adcm
adcm$STATUS <- c(rep("ongoing", 2000), rep("resolved", 1685))
basic_table() %>%
split_cols_by("ARMCD") %>%
add_colcounts() %>%
split_cols_by("STATUS") %>%
summarize_num_patients("USUBJID") %>%
build_table(adcm, alt_counts_df = adsl)
will give the error message
Error in FUN(X[[i]], ...) :
alt_counts_df (or df) appears incompatible with column-split structure. Offending column subset expression: ((!is.na(ARMCD) & ARMCD %in% "ARM A")) & (!is.na(STATUS) & STATUS %in%
Original error message: object 'STATUS' not foundalt_counts_df (or df) appears incompatible with column-split structure. Offending column subset expression: "ongoing")
Original error message: object 'STATUS' not found
If we do
basic_table() %>%
split_cols_by("ARMCD") %>%
add_colcounts() %>%
split_cols_by("STATUS") %>%
summarize_num_patients("USUBJID") %>%
build_table(adcm)
how can we get the patients count in the column header?
Hi @shajoezhu and @yangx61 , this is new feature requested for tern, but potentially need rtables update I assume?