Skip to content

Commit 1ae4a59

Browse files
committed
fixes requested by CRAN
1 parent 09a844b commit 1ae4a59

File tree

12 files changed

+48
-26
lines changed

12 files changed

+48
-26
lines changed

DESCRIPTION

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: posologyr
22
Title: Individual Dose Optimization using Population Pharmacokinetics
3-
Version: 1.2.0
3+
Version: 1.2.1
44
Authors@R: c(
55
person("Cyril","Leven",role = c("aut", "cre","cph"),
66
email = "cyril.leven@chu-brest.fr",
@@ -12,8 +12,9 @@ Authors@R: c(
1212
Description: Determine individual pharmacokinetic (and
1313
pharmacokinetic-pharmacodynamic) profiles and use them to personalise drug
1414
regimens. You provide the data and a population pharmacokinetic model,
15-
`posologyr` provides the individual a posteriori estimate and allows you to
16-
determine the optimal dosing.
15+
'posologyr' provides the individual a posteriori estimate and allows you to
16+
determine the optimal dosing. The empirical Bayes estimates are computed as
17+
described in Kang et al. (2012) <doi:10.4196/kjpp.2012.16.2.97>.
1718
License: AGPL-3
1819
Encoding: UTF-8
1920
Roxygen: list(markdown = TRUE)

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# posologyr v1.2.1
2+
* Add a reference to Kang et al. (2012) <doi:10.4196/kjpp.2012.16.2.97> in the DESCRIPTION (as requested by CRAN)
3+
* Fix messages to the console in the internal function `posologyr()` (as requested by CRAN)
4+
* Fix assignment to parent environment in dose optim functions, using `parent.frame()` (as requested by CRAN)
5+
16
# posologyr v1.2.0
27

38
## Additional features

R/dosing_optim.R

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ poso_time_cmin <- function(dat=NULL,prior_model=NULL,tdm=FALSE,
253253
cmin_ppk_model[,endpoint] < target_cmin,
254254
]$time) - time_last_dose
255255
#here cmin_distribution is a point estimate of the endpoint
256-
cmin_distribution <<-
256+
cmin_distribution <-
257257
cmin_ppk_model[cmin_ppk_model$time == (time_to_target +
258258
time_last_dose),endpoint]
259259
}
@@ -386,6 +386,9 @@ poso_dose_auc <- function(dat=NULL,prior_model=NULL,tdm=FALSE,
386386

387387
object <- posologyr(prior_model,dat,nocb)
388388

389+
#initialization of conc_distribution to avoid a global variable
390+
auc_distribution <- 0
391+
389392
if(tdm){ #using TDM data
390393
#input validation
391394
if (is.null(time_dose)){
@@ -448,13 +451,12 @@ poso_dose_auc <- function(dat=NULL,prior_model=NULL,tdm=FALSE,
448451
ifelse(nocb,"nocb","locf"))
449452

450453
auc_proposal <- max(auc_ppk_model$AUC)-min(auc_ppk_model$AUC)
451-
auc_distribution <<- auc_proposal #to parent environment
454+
p <- parent.frame()
455+
p$auc_distribution <- auc_proposal
452456
#return the difference between the computed auc and the target
453457
delta_auc <- (target_auc - auc_proposal)^2
454458
return(delta_auc)
455459
}
456-
#initialization of conc_distribution to avoid a global variable
457-
auc_distribution <- 0
458460

459461
optim_dose_auc <- stats::optim(starting_dose,err_dose_tdm,
460462
time_dose=time_dose,target_auc=target_auc,
@@ -525,7 +527,8 @@ poso_dose_auc <- function(dat=NULL,prior_model=NULL,tdm=FALSE,
525527
auc_index <- ceiling(p * n_auc)
526528

527529
# assign the distribution of auc to the parent environment
528-
auc_distribution <<- sorted_auc
530+
p <- parent.frame()
531+
p$auc_distribution <- sorted_auc
529532

530533
if (greater_than){
531534
auc_proposal <- sorted_auc[n_auc - auc_index]
@@ -534,7 +537,8 @@ poso_dose_auc <- function(dat=NULL,prior_model=NULL,tdm=FALSE,
534537
}
535538
} else {
536539
auc_proposal <- max(auc_ppk_model$AUC)-min(auc_ppk_model$AUC)
537-
auc_distribution <<- auc_proposal
540+
p <- parent.frame()
541+
p$auc_distribution <- auc_proposal
538542
}
539543

540544
#return the difference between the computed AUC and the target
@@ -739,7 +743,8 @@ poso_dose_conc <- function(dat=NULL,prior_model=NULL,tdm=FALSE,
739743
ifelse(nocb,"nocb","locf"))
740744

741745
conc_proposal <- ctime_ppk_model[,endpoint]
742-
conc_distribution <<- conc_proposal #to parent environment
746+
p <- parent.frame()
747+
p$conc_distribution <- conc_proposal
743748
#return the difference between the computed ctime and the target
744749
delta_conc <- (target_conc - conc_proposal)^2
745750
return(delta_conc)
@@ -803,7 +808,8 @@ poso_dose_conc <- function(dat=NULL,prior_model=NULL,tdm=FALSE,
803808
conc_index <- ceiling(p * n_conc)
804809

805810
# assign the distribution of concentrations to the parent environment
806-
conc_distribution <<- sorted_conc
811+
p <- parent.frame()
812+
p$conc_distribution <- sorted_conc
807813

808814
if (greater_than){
809815
conc_proposal <- sorted_conc[n_conc - conc_index]
@@ -812,7 +818,8 @@ poso_dose_conc <- function(dat=NULL,prior_model=NULL,tdm=FALSE,
812818
}
813819
} else {
814820
conc_proposal <- ctime_ppk_model[,endpoint]
815-
conc_distribution <<- conc_proposal
821+
p <- parent.frame()
822+
p$conc_distribution <- conc_proposal
816823
}
817824

818825
#return the difference between the computed ctime and the target
@@ -979,7 +986,8 @@ poso_inter_cmin <- function(dat=NULL,prior_model=NULL,dose,target_cmin,
979986
cmin_index <- ceiling(p * n_cmin)
980987

981988
# assign the distribution of cmin to the parent environment
982-
cmin_distribution <<- sorted_cmin
989+
p <- parent.frame()
990+
p$cmin_distribution <- sorted_cmin
983991

984992
if (greater_than){
985993
cmin_proposal <- sorted_cmin[n_cmin - cmin_index]
@@ -988,7 +996,8 @@ poso_inter_cmin <- function(dat=NULL,prior_model=NULL,dose,target_cmin,
988996
}
989997
} else {
990998
cmin_proposal <- cmin_ppk_model[,endpoint]
991-
cmin_distribution <<- cmin_proposal
999+
p <- parent.frame()
1000+
p$cmin_distribution <- cmin_proposal
9921001
}
9931002

9941003
#return the difference between the computed cmin and the target,

R/posologyr.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ posologyr <- function(prior_model=NULL,dat=NULL,nocb=FALSE){
7272
# check the validity of the compiled model and call rxode2::rxode
7373
# on invalid models
7474
if (!prior_model$ppk_model$isValid()){
75-
cat("Invalid rxode2 model, trying to recompile...")
75+
warning("Invalid rxode2 model, trying to recompile...")
7676
prior_model$ppk_model <- try(rxode2::rxode(prior_model$ppk_model),
7777
silent=TRUE)
7878
if (prior_model$ppk_model$isValid()){
79-
cat("Success","\n")
79+
message("Success","\n")
8080
} else {
8181
stop("Failed. The rxode2 model is still invalid. Aborting",
8282
call. = FALSE)

docs/404.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/LICENSE.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/index.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/authors.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/news/index.html

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)