First row count and persentage does not align with subsequent rows
jagadishkatam opened this issue · comments
Hi @mstackhouse,
Appreciate your prompt response, it worked for me as per your suggestion.
However i am struck with another issue, the 'subjects with any adverse events' does not align with adverse event counts and percentage. I am not sure of the reason.
I am using the same code as given earlier except for below update
tbl <- create_table(dt) %>%
define(row_label1, visible = FALSE) %>%
define(row_label2, label = "", indent = .25) %>%
define(var1_Placebo, label = "Placebo", align = "left", n = 86) %>%
define(var1_Xanomeline_High_Dose, label = "Xanomeline High Dose", align = "left", n = 84) %>%
define(var1_Xanomeline_Low_Dose, label = "Xanomeline Low Dose", align = "left", n = 84) %>%
define(ord_layer_index, visible = FALSE) %>%
define(ord_layer_1, visible = FALSE, blank_after = TRUE) %>%
define(ord_layer_2, visible = FALSE)
![image](https://private-user-images.githubusercontent.com/83913148/269721768-71398fa4-ec23-4c58-a890-614197cbfa1a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA2MDk3MjYsIm5iZiI6MTcyMDYwOTQyNiwicGF0aCI6Ii84MzkxMzE0OC8yNjk3MjE3NjgtNzEzOThmYTQtZWMyMy00YzU4LWE4OTAtNjE0MTk3Y2JmYTFhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzEwVDExMDM0NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWMyMWExN2M3NDY4ZWQ5NmU2OGIzZTVkNDI1OTI0OGZhMGQyMjYzNmE4MjM3YWNmOWQyMzNjZWFmZmJjZjIzOTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Q2kwQeCVNiIjodKF6mPwbyqT3NVwfqBOANCg9x7pVxM)
Originally posted by @jagadishkatam in #135 (comment)
You can override numeric display formats using set_format_strings()
. Here's how you can correct this specific case:
t <- Tplyr::tplyr_table(adae, TRTA) %>%
set_pop_data(adsl) %>%
set_pop_treat_var(TRTA) %>%
set_pop_where(TRUE) %>%
Tplyr::add_layer(
group_count(all, by='Subjects with any Adverse Events') %>%
set_format_strings(f_str("xx (xxx.x%)", distinct_n, distinct_pct))
) %>%
set_distinct_by(USUBJID) %>%
Tplyr::add_layer(
group_count(vars(AEBODSYS,AEDECOD)) %>%
set_format_strings(f_str("xx (xxx.x%)", distinct_n, distinct_pct))
) %>%
set_distinct_by(USUBJID)
dt <- t %>% Tplyr::build()
Thank you @mstackhouse , appreciate your help.