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

Named logit/expit #824

Merged
merged 11 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ S3method(rxSolve,rxode2tos)
S3method(rxTrans,character)
S3method(rxTrans,default)
S3method(rxUdfUi,default)
S3method(rxUdfUi,expit)
S3method(rxUdfUi,linMod)
S3method(rxUdfUi,linMod0)
S3method(rxUdfUi,linModA)
Expand All @@ -169,6 +170,7 @@ S3method(rxUdfUi,linModD)
S3method(rxUdfUi,linModD0)
S3method(rxUdfUi,linModM)
S3method(rxUdfUi,linModM0)
S3method(rxUdfUi,logit)
S3method(rxUdfUi,ribeta)
S3method(rxUdfUi,ribinom)
S3method(rxUdfUi,ricauchy)
Expand Down Expand Up @@ -341,6 +343,7 @@ export(.udfEnvSet)
export(.udfEnvSetUdf)
export(.udfExists)
export(.udfMd5Info)
export(.uiArg)
export(.useUtf)
export(.vecDf)
export(ELU)
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# rxode2 (development version)

- Add `logit`/`expit` named expressions, that is `logit(x, high=20)`
becomes `logit(x, 0, 20)` in ui models.

- Updated random ui models like `rxnorm(sd=10)` to accept complex
numeric expressions like `rxnorm(sd=10+1)`.

- Updated random ui models to accept complex non-numeric expressions
like `rxnorm(sd=a+b)`

- Rework the `tad()` and related functions so they use the same
interface as compartments (this way they do not depend on the order
of compartments); See #815. For mu-referencing, Also allow dummy
Expand Down
11 changes: 5 additions & 6 deletions R/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@ d/dt(blood) = a*intestine - b*blood
.arg <- str2lang(arg)
.ret <- bquote({
.(.dotArg) <- as.character(substitute(.(.arg)))
.dp <- deparse1(substitute(.(.arg)))
.tmp <- suppressWarnings(try(force(.(.arg)), silent=TRUE))
if (!inherits(.tmp, "try-error")) {
if (is.character(.tmp)) {
.(.dotArg) <- .(.arg)
}
}
.(.dotArg) <- .uiArg(.(.dotArg), .tmp, .dp)
})
lapply(seq_along(.ret)[-1], function(i) {
.ret[[i]]
Expand Down Expand Up @@ -111,7 +108,9 @@ d/dt(blood) = a*intestine - b*blood
"rxbinom"=c("size", "prob"))
.lst2 <- .lst
names(.lst2) <- gsub("rx", "ri", names(.lst2))
.lst <- c(.lst, .lst2)
.lst <- c(.lst, .lst2,
list("logit"=c("x"=NA, "low"=0, "high"=1),
"expit"=c("x"=NA, "low"=0, "high"=1)))
paste0("# This file is generated by .generateRandomUiFuns() in build.R\n## nocov start\n",
vapply(names(.lst), function(fun) {
if (is.null(names(.lst[[fun]]))) {
Expand Down
3 changes: 2 additions & 1 deletion R/rudfui.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ rxUdfUiParsing <- function() {
}
expr <- .t
} else {
stop("rxode2 ui user function '", .c, "' failed to produce code that could be parsed in the",

stop("rxode2 ui user function '", .c, "' failed to produce code that could be parsed",
call.=FALSE)
}
.handleUdifUiBeforeOrAfter("before", .e, env, .c)
Expand Down
Loading
Loading