Skip to content
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
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@
^dev$
^\.posit$
^temp$
^codecov\.yml$
^vignettes/\.quarto$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ inst/rust/template/*

# Example runs
data-raw/Runs/
data-raw/errors.xlsx
inst/Examples/


Expand Down
19 changes: 0 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: Pmetrics
Title: Pmetrics for Population Modeling and Simulation
Version: 3.2.6
Version: 3.2.7
Authors@R: c(
person("Michael", "Neely", , "mneely@usc.edu", role = c("aut", "cre")),
person("Julián", "Otálvaro", , "juliandavid347@gmail.com", role = "aut"),
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export(PM_sim)
export(PM_step)
export(PM_tree)
export(PM_tutorial)
export(PM_upgrade)
export(PM_valid)
export(PMbuild)
export(PMcheck)
Expand Down Expand Up @@ -157,6 +158,7 @@ export(two_comp_bolus_cl)
export(two_comp_iv)
export(two_comp_iv_cl)
export(zBMI)
importFrom(DT,datatable)
importFrom(R6,R6Class)
importFrom(bslib,
accordion,
Expand Down Expand Up @@ -264,6 +266,7 @@ importFrom(graphics,
segments,
text
)
importFrom(magrittr,not)
importFrom(parallel,
clusterExport,
makeCluster,
Expand Down Expand Up @@ -304,6 +307,7 @@ importFrom(readr,
importFrom(rlang,
":=",
.data,
.env,
set_names
)
importFrom(shiny,
Expand Down
20 changes: 12 additions & 8 deletions R/PM_cov.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ PM_cov <- R6::R6Class(
if (file.exists(file.path(path, "posterior.csv"))) {
posts <- readr::read_csv(file = file.path(path, "posterior.csv"), show_col_types = FALSE)
} else if (inherits(data, "PM_cov") & !is.null(data$data)) { # file not there, and already PM_cov
class(data$data) <- c("PM_cov_data", "data.frame")
return(data$data)
upgraded_data <- PM_upgrade(data$data)
class(upgraded_data) <- c("PM_cov_data", "data.frame")
return(upgraded_data)
} else {
cli::cli_warn(c(
"!" = "Unable to generate covariate-posterior information.",
Expand All @@ -110,8 +111,9 @@ PM_cov <- R6::R6Class(
if (file.exists(file.path(path, "covs.csv"))) {
covs <- readr::read_csv(file = file.path(path, "covs.csv"), show_col_types = FALSE)
} else if (inherits(data, "PM_cov")) { # file not there, and already PM_cov
class(data$data) <- c("PM_cov_data", "data.frame")
return(data$data)
upgraded_data <- PM_upgrade(data$data)
class(upgraded_data) <- c("PM_cov_data", "data.frame")
return(upgraded_data)
} else {
cli::cli_warn(c(
"!" = "Unable to generate covariate-posterior information.",
Expand All @@ -120,7 +122,9 @@ PM_cov <- R6::R6Class(
return(NULL)
}

covs <- covs |> mutate(block = block + 1)
covs <- covs |>
mutate(occasion = block + 1) |>
select(-block)


post_mean <- posts |>
Expand All @@ -140,10 +144,10 @@ PM_cov <- R6::R6Class(
dplyr::left_join(post_mean, covs, by = "id"),
dplyr::left_join(post_med, covs, by = "id")
) |>
select(id, time, block, icen, everything())
select(id, time, occasion, icen, everything())

class(res) <- c("PM_cov_data", "data.frame")
attr(res, "ncov") <- ncol(covs) - 3 # subtract id, time, block
attr(res, "ncov") <- ncol(covs) - 3 # subtract id, time, occasion

return(res)
}
Expand Down Expand Up @@ -564,7 +568,7 @@ summary.PM_cov <- function(object, icen = "median", ...) {

sumCov <- data |>
group_by(id) |>
dplyr::summarize(across(c(-time, -block), ~ purrr::exec(icen, x = .x, na.rm = TRUE))) |>
dplyr::summarize(across(c(-time, -occasion), ~ purrr::exec(icen, x = .x, na.rm = TRUE))) |>
mutate(icen = !!icen)

return(sumCov)
Expand Down
15 changes: 9 additions & 6 deletions R/PM_cycle.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ PM_cycle <- R6::R6Class(
write.csv(raw, file.path(path, "cycles.csv"), row.names = FALSE)
}
} else if (inherits(data, "PM_cycle") & !is.null(data$data)) { # file not there, and already PM_cycle
class(data$data) <- c("PM_cycle_data", "list")
return(data$data)
upgraded_data <- PM_upgrade(data$data)
class(upgraded_data) <- c("PM_cycle_data", "list")
return(upgraded_data)
} else {
cli::cli_warn(c(
"!" = "Unable to generate cycle information.",
Expand All @@ -153,8 +154,9 @@ PM_cycle <- R6::R6Class(
), show_col_types = FALSE
) |> filter(!is.na(obs))
} else if (inherits(data, "PM_cycle")) { # file not there, and already PM_op
class(data$data) <- c("PM_cycle_data", "list")
return(data$data)
upgraded_data <- PM_upgrade(data$data)
class(upgraded_data) <- c("PM_cycle_data", "list")
return(upgraded_data)
} else {
cli::cli_warn(c(
"!" = "Unable to generate cycle information.",
Expand All @@ -167,8 +169,9 @@ PM_cycle <- R6::R6Class(
if (file.exists(file.path(path, "settings.json"))) {
config <- jsonlite::fromJSON(file.path(path, "settings.json"))
} else if (inherits(data, "PM_cycle") & !is.null(data$data)) { # file not there, and already PM_op
class(data$data) <- c("PM_cycle_data", "list")
return(data$data)
upgraded_data <- PM_upgrade(data$data)
class(upgraded_data) <- c("PM_cycle_data", "list")
return(upgraded_data)
} else {
cli::cli_warn(c(
"!" = "Unable to generate cycle information.",
Expand Down
Loading
Loading