Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are examples for unit() out of date due to a breaking change? #87

Closed
pa-nathaniel opened this issue Sep 27, 2023 · 1 comment
Closed

Comments

@pa-nathaniel
Copy link

I am on Capr 2.0.7 and I tried following the example in

Capr/vignettes/Examples.Rmd

Lines 136 to 179 in e44ec1c

**Persons with new type 2 diabetes mellitus at first dx rx or lab**
https://atlas-phenotype.ohdsi.org/#/cohortdefinition/90
```{r, eval=FALSE}
library(Capr)
cs0 <- cs(descendants(443238, 201820, 442793),
descendants(exclude(195771, 201254, 435216, 761051, 4058243, 40484648)),
name = "Type 2 diabetes mellitus (diabetes mellitus excluding T1DM and secondary)")
cs1 <- cs(descendants(201254, 435216, 40484648),
name = "Type 1 diabetes mellitus")
cs2 <- cs(descendants(195771),
name = "Secondary diabetes mellitus")
cs3 <- cs(descendants(4184637, 37059902),
name = "Hemoglobin A1c (HbA1c) measurements")
cs4 <- cs(descendants(21600744),
name = "Drugs for diabetes except insulin")
ch <- cohort(
entry = entry(
conditionOccurrence(cs0),
drugExposure(cs4),
measurement(cs3, valueAsNumber(bt(6.5, 30)), unit("%")),
measurement(cs3, valueAsNumber(bt(48, 99)), unit("mmol/mol")),
observationWindow = continuousObservation(priorDays = 365)
),
attrition = attrition(
'no T1D' = withAll(
exactly(0, conditionOccurrence(cs1), duringInterval(eventStarts(-Inf, 0)))
),
'no secondary diabettes' = withAll(
exactly(0, conditionOccurrence(cs2), duringInterval(eventStarts(-Inf, 0)))
)
),
exit = exit(
endStrategy = observationExit()
)
)

However it returned an error "Error in is.unit(x) : argument "x" is missing, with no default"

I was able to reduce it to the following calls:

library(Capr)

cs3 <- cs(descendants(4184637, 37059902),
          name = "Hemoglobin A1c (HbA1c) measurements")

measurement(cs3, valueAsNumber(bt(6.5, 30)), unit(units = "%"))

This gave me the error

Error in is.unit(x) : argument "x" is missing, with no default

I also tried running the code in

tt <- unit(8713L) #gram per deciliter
within the tests and also got an error

> tt <- unit(8713L)
Error in unit(8713L) : argument "units" is missing, with no default

My hypothesis is that there has been a breaking to unit() and the examples need to be updated. Is that right?

@pa-nathaniel pa-nathaniel changed the title Example is unit() broken? Are examples for is unit() out of date due to a breaking change? Sep 27, 2023
@pa-nathaniel pa-nathaniel changed the title Are examples for is unit() out of date due to a breaking change? Are examples for unit() out of date due to a breaking change? Sep 27, 2023
@pa-nathaniel
Copy link
Author

My bad. It turns out I had a namespace conflict between grid::unit() and Capr::unit(). When I explicitly called Capr::unit() it worked fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant