pharmaverse / pharmaverse/rtables
[Bug]: split funs which use add_combo_facet don't work in row splits (do work in cols)
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 260
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
What happened?
Some of the split-time validation thats happening for row splits is brittle in a way that it shouldn't be, and is running afoul of a buglet in add_combo_facet
Specifically, add_combo_facet seems to be creating a split result object whose labels component is missing the name (name is "") for the added facet. This is a bug, but not a very important one, because as you can see in the columns case, the core tabulation machinery doesn't care about the names on the labels vector (apparently).
Something is tripping it up in .checkvarsok, though.
As a side note, it seems that all our tests and examples only use add_combo_facet in column splits...
Relevant log output
mysplitfun <- make_split_fun(post = list(add_overall_facet("all", "all of them")))
lyt <- basic_table() %>%
split_rows_by("STRATA1", split_fun = mysplitfun) %>%
analyze("AGE")
build_table(lyt, DM)
Error in .checkvarsok(spl, df) :
variable(s) [AGE] not present in data. (AnalyzeVarSplit)
In addition: Warning message:
In rep(vals, length.out = nrow(full_parent_df[[1]])) :
first element used of 'length.out' argument
lyt2 <- basic_table() %>%
split_cols_by("STRATA1", split_fun = mysplitfun) %>%
analyze("AGE")
build_table(lyt2, DM)
A B C all of them
——————————————————————————————————————————
Mean 33.74 34.10 34.79 34.22
Code of Conduct
- I agree to follow this project's Code of Conduct.
Contribution Guidelines
- I agree to follow this project's Contribution Guidelines.
Security Policy
- I agree to follow this project's Security Policy.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the row-split and column-split examples in the issue, then trace add_combo_facet and .checkvarsok during build_table. The fix should make the reproduced row split succeed without the missing-variable error while preserving the currently working column split behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100