rtables
rtables copied to clipboard
section_div in single var analyze call puts divider between each row generated by afun, rather than only after the last one
library(rtables)
lyt <- basic_table() %>% analyze("SEX", section_div = " ")
gives us
> build_table(lyt, ex_adsl)
all obs
——————————————————————————
F 222
M 166
U 9
UNDIFFERENTIATED 3
Instead of what it should generate, which is:
all obs
——————————————————————————
F 222
M 166
U 9
UNDIFFERENTIATED 3
Note when analyze is given multiple variables, we get the desired behavior:
lyt <- basic_table() %>% analyze(c("SEX", "STRATA1"), section_div = " ")
gives us
> build_table(lyt, ex_adsl)
all obs
————————————————————————————
SEX
F 222
M 166
U 9
UNDIFFERENTIATED 3
STRATA1
A 122
B 135
C 143
Multiple calls to analyze
also result in the buggy behavior:
lyt <- basic_table() %>% analyze("SEX", section_div = " ") %>% analyze("STRATA1")
gives
> build_table(lyt, ex_adsl)
all obs
————————————————————————————
SEX
F 222
M 166
U 9
UNDIFFERENTIATED 3
STRATA1
A 122
B 135
C 143
Its a little less clear what the correct behavior is here but only in terms of whether the second analyze call should inherit the section_div or not. Either way, section div should only place lines after sections.
I was going to prepare a patch but it appears the meaning of section divider has deviated drastically from its original usage so more discussion may be needed