Skip to content

Packages#353

Merged
mnneely merged 9 commits into
mainfrom
packages
May 23, 2026
Merged

Packages#353
mnneely merged 9 commits into
mainfrom
packages

Conversation

@mnneely
Copy link
Copy Markdown
Contributor

@mnneely mnneely commented May 22, 2026

Clean package dependencies, introduce report app

Copilot AI review requested due to automatic review settings May 22, 2026 23:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR cleans up package dependencies (removing several hard Imports), switches filesystem operations to base R, and updates reporting to primarily launch an external Shiny reporting app (PmetricsReports) with an HTML-render fallback.

Changes:

  • Replace fs helpers with base dir.create(), unlink(), file.exists(), etc., and remove related Imports.
  • Rework PM_report() to launch the PmetricsReports app when available, with legacy HTML rendering as a fallback.
  • Replace TruncatedNormal::rtmvnorm() usage with a new internal lower-bounded MVN sampler and update report templates/UI options accordingly.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/testthat/test-pm-fit-prior-parameters.R Switch test directory creation from fs::dir_create() to base dir.create().
R/PMutilities.R Replace openHTML/clear_build implementations and add internal PM_rtmvnorm() sampler.
R/PMoptions.R Update options storage path creation and change reporting option to “app”-only.
R/Pmetrics-package.R Remove roxygen @importFrom entries for dropped/softened dependencies.
R/PM_valid.R Namespace-qualify kmeans() via stats::kmeans().
R/PM_sim.R Replace truncated MVN sampling callsites; large reformatting/realignment of code blocks.
R/PM_result.R Replace fs::dir_create() with base dir.create() for binary copy path creation.
R/PM_report.R Introduce “report app first” flow with fallback to Rmd rendering.
R/PM_model.R Update run directory creation and reporting messages for “app launched” semantics.
R/PM_help.R Remove rstudioapi usage; rely on environment variables for IDE version info.
NAMESPACE Drop imports for packages moved out of Imports (e.g., DT, TruncatedNormal, lifecycle, mclust, npde).
man/PM_report.Rd Update documentation to match new reporting behavior and parameter semantics.
inst/report/templates/ggplot.Rmd Namespace DT usage and remove ggpubr::grids() dependency in plots.
inst/report/templates/ggplot_rust.Rmd Same template updates as ggplot.Rmd.
DESCRIPTION Remove several Imports (fs/DT/lifecycle/etc.) and add some to Suggests (including PmetricsReports).
Files not reviewed (1)
  • man/PM_report.Rd: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/PMutilities.R Outdated
Comment thread R/PMutilities.R
Comment thread R/PMutilities.R Outdated
Comment thread R/PMutilities.R
Comment thread DESCRIPTION
Comment thread R/PM_report.R Outdated
Comment thread R/PM_report.R
Comment thread R/PM_result.R Outdated
Copilot AI review requested due to automatic review settings May 22, 2026 23:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • man/PM_report.Rd: Language not supported

Comment thread R/PM_report.R Outdated
Comment thread R/PMutilities.R Outdated
Copilot AI review requested due to automatic review settings May 22, 2026 23:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • man/PM_report.Rd: Language not supported

Comment thread R/PMutilities.R
Comment on lines +1208 to +1211
d <- length(mean)
if (length(lb) != d) stop("lb length must equal length(mean)")
if (!all(dim(sigma) == c(d, d))) stop("sigma must be d x d")

Comment thread R/PMutilities.R

draws <- draws + batch
if (draws > max_draws) {
stop("Exceeded max_draws before filling sample; truncation region may be too restrictive")
Comment thread R/PM_report.R
Comment on lines 19 to +41
PM_report <- function(x, template, path, show = TRUE, quiet = TRUE) {
template_missing <- missing(template)
path_missing <- missing(path)

if (!is(x, "PM_result")) {
cli::cli_abort(c("x" = "This function expects a valid PM_result object from PM_load."))
}

if (missing(template)) {
template <- getPMoptions("report_template")
if (!template_missing && identical(template, "none")) {
return(invisible(0))
}

if (template == "none") {
return()
if (is.null(x$final$data) & is.null(x$op$data) & is.null(x$cycle$data)) {
return(invisible(-1)) # no data found
}

templateFile <- switch(template,
plotly = system.file("report/templates/plotly.Rmd", package = "Pmetrics"),
ggplot = system.file("report/templates/ggplot.Rmd", package = "Pmetrics"),
ggplot_rust = system.file("report/templates/ggplot_rust.Rmd", package = "Pmetrics")
)
# templateFile = system.file("report/templates/ggplot.Rmd", package = "Pmetrics")
render_html_fallback <- function() {
fallback_template <- if (template_missing) getPMoptions("report_template") else template
if (identical(fallback_template, "none")) {
return(invisible(0))
}
if (identical(fallback_template, "app") || is.null(fallback_template)) {
fallback_template <- "ggplot"
@mnneely mnneely marked this pull request as ready for review May 23, 2026 00:17
@mnneely mnneely merged commit bfe274a into main May 23, 2026
10 checks passed
@mnneely mnneely deleted the packages branch May 23, 2026 00:17
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

Successfully merging this pull request may close these issues.

2 participants