Currently, ref_group appears to require the reference level to be included in the levels retained by split_fun. For example:
table(DM$ARM)
A: Drug X B: Placebo C: Combination
121 106 129
lyt <- basic_table() |>
split_cols_by(
"ARM",
split_fun = keep_split_levels("A: Drug X"),
ref_group = "B: Placebo"
) |>
analyze("AGE")
build_table(lyt, DM)
results in:
Error in .add_ref_extras(spl, df, ret) : length(ref_ind) == 1 is not TRUE
From the user perspective, this seems to be an unnecessary and unreasonable limitation. I think ref_group should be allowed to be any valid level of the split variable, even if that level is not displayed or not observed in the data.
This includes:
- A factor level that exists but is not observed in the data.
- A factor level that is not present at all - in this case, perhaps a warning would be appropriate.
Simply put, the split function controls what is displayed, while ref_group should be allowed to specify the reference level independently.
Currently,
ref_groupappears to require the reference level to be included in the levels retained bysplit_fun. For example:results in:
From the user perspective, this seems to be an unnecessary and unreasonable limitation. I think
ref_groupshould be allowed to be any valid level of the split variable, even if that level is not displayed or not observed in the data.This includes:
Simply put, the split function controls what is displayed, while
ref_groupshould be allowed to specify the reference level independently.