insightsengineering / insightsengineering/crane
Inexplicit error message when `by` variable and `include` variable is same in `tbl_roche_summary()`
- Dominant language
- R
- Stars
- 15
- Forks
- 7
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 5
Description
An error message "Error in `rep_named()`:! `names` must be `NULL` or a character vector, not an empty integer vector." generated when I execute the following code:
```r
library(teal.modules.clinical)
library(formatters)
library(dplyr)
ADSL <- tmc_ex_adsl %>% mutate(ITTFL = with_label(factor("Y"), "Intent-To-Treat Population Flag"), DTHFL = sample(c("Y", "N"), 200, replace = TRUE), AEWITHFL = sample(c("Y", "N"), 200, replace = TRUE))
.raw_data <- list2env(list(ADSL = ADSL))
lockEnvironment(.raw_data)
library(dplyr)
ANL <- dplyr::select(ADSL, STUDYID, USUBJID, SEX, ACTARM)
library(crane)
table <- crane::tbl_roche_summary(data = ANL, by = "ACTARM", include = "ACTARM", nonmissing = "no", percent = "column")
table
```
I understand that the issue is caused by the same variable "ACTARM" is being used for `by` variable and `include` variable. However, the error message is unclear and doesn't help users understand the root cause.
Contributor guide
Research direction
Start at the tbl_roche_summary() entry point and reproduce the example with ACTARM passed to both by and include. Trace where the rep_named() error is produced, then make the failure explain that the same variable cannot be used for both arguments and rerun the supplied example to verify the message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100