error when argument countBy = "person" only for summariseCodeUse

Open Beginner friendly
#255 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
r
Domain
data

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.

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)
Dominant language
R
Stars
18
Forks
9
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from darwin-eu/CodelistGenerator

All issues in darwin-eu/CodelistGenerator

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.