lyt <- basic_table() %>%
split_cols_by("ARM") %>%
analyze(c("AGE", "BMRKR2"))
tbl <- build_table(lyt, ex_adsl)
tbl
# Let's look at the splits in more detail
lyt1 <- basic_table() %>% split_cols_by("ARM")
lyt1
# add an analysis (summary)
lyt2 <- lyt1 %>%
analyze(c("AGE", "COUNTRY"),
afun = list_wrap_x(summary),
format = "xx.xx"
)
lyt2
tbl2 <- build_table(lyt2, DM)
tbl2
# By default sequentially adding layouts results in nesting
library(dplyr)
DM_MF <- DM %>%
filter(SEX %in% c("M", "F")) %>%
mutate(SEX = droplevels(SEX))
lyt3 <- basic_table() %>%
split_cols_by("ARM") %>%
split_cols_by("SEX") %>%
analyze(c("AGE", "COUNTRY"),
afun = list_wrap_x(summary),
format = "xx.xx"
)
lyt3
tbl3 <- build_table(lyt3, DM_MF)
tbl3
# nested=TRUE vs not
lyt4 <- basic_table() %>%
split_cols_by("ARM") %>%
split_rows_by("SEX", split_fun = drop_split_levels) %>%
split_rows_by("RACE", split_fun = drop_split_levels) %>%
analyze("AGE")
lyt4
tbl4 <- build_table(lyt4, DM)
tbl4
lyt5 <- basic_table() %>%
split_cols_by("ARM") %>%
split_rows_by("SEX", split_fun = drop_split_levels) %>%
analyze("AGE") %>%
split_rows_by("RACE", nested = FALSE, split_fun = drop_split_levels) %>%
analyze("AGE")
lyt5
tbl5 <- build_table(lyt5, DM)
tbl5
Run the code above in your browser using DataLab