darwin-eu / darwin-eu/CodelistGenerator
error when argument countBy = "person" only for summariseCodeUse
- Dominant language
- R
- Stars
- 18
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When using the argument summariseCodeUse and setting countBy = "person" an error message occurs.
**To Reproduce**
Steps to reproduce the behavior:
```
atc2 <- c("ANTIEMETICS AND ANTINAUSEANTS" ,
"DRUGS FOR FUNCTIONAL GASTROINTESTINAL DISORDERS" )
atc2_codelist <- getATCCodes(
cdm,
level = c("ATC 2nd"),
name = atc2,
doseForm = NULL,
doseUnit = NULL,
routeCategory = NULL,
type = "codelist"
)
atc2_codelist_n <- summariseCodeUse(atc2_codelist,
countBy = "person",
byConcept = FALSE,
cdm = cdm)
```
```
error message:
Error in `dplyr::mutate()` at CodelistGenerator/R/summariseCodeUse.R:417:5:
ℹ In argument: `variable_name = dplyr::if_else(...)`.
Caused by error in `.data$standard_concept_name`:
! Column `standard_concept_name` not found in `.data`.
Run `rlang::last_trace()` to see where the error occurred.
```
**Expected behavior**
A clear and concise description of what you expected to happen.
Should return code use for person counts only but an error message occurs. For now just setting to default where it returns both record and person counts.
**Screenshots**
NA
**Desktop (please complete the following information):**
- Browser chrome
- Version Cran version codelistgenerator as of todays date (26/6/26)
Contributor guide
Research direction
Start in CodelistGenerator/R/summariseCodeUse.R at the reported line 417 and trace the countBy = "person" path that accesses standard_concept_name. Reproduce the supplied summariseCodeUse example, then verify that requesting person counts completes without the missing-column error and returns person counts only.
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
- Clearly specified
- Newbie friendliness
- 72/100