Skip to content

Conversation

@smasongarrison
Copy link
Member

Updated vignettes to gracefully handle cases where OpenMx or EasyMx are not installed, preventing errors on older R versions. Added conditional checks and informative messages in the vignette code. Updated cran-comments.md to document this enhancement.

Updated vignettes to gracefully handle cases where OpenMx or EasyMx are not installed, preventing errors on older R versions. Added conditional checks and informative messages in the vignette code. Updated cran-comments.md to document this enhancement.
@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.42%. Comparing base (c6d566d) to head (9674d45).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #108   +/-   ##
=======================================
  Coverage   84.42%   84.42%           
=======================================
  Files          25       25           
  Lines        3982     3982           
=======================================
  Hits         3362     3362           
  Misses        620      620           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
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 aims to improve vignette compatibility by adding conditional checks to handle cases where OpenMx or EasyMx packages are not installed, particularly for older R versions. The changes add graceful fallbacks with informative messages and synthetic data generation.

Key Changes:

  • Added conditional package loading with requireNamespace() checks for EasyMx and OpenMx in the vignette setup
  • Wrapped model fitting code blocks with conditionals to prevent errors when EasyMx is unavailable
  • Added synthetic data generation as a fallback when OpenMx is not installed
  • Updated cran-comments.md to document this enhancement

Reviewed changes

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

File Description
vignettes/v1_modelingvariancecomponents.Rmd Added conditional checks for OpenMx/EasyMx availability, synthetic data fallback, and wrapped model fitting examples in conditionals
vignettes/v1_modelingvariancecomponents.html Regenerated HTML output reflecting the Rmd changes with updated timestamps and removed warning messages
cran-comments.md Updated description to document vignette compatibility improvements for systems without OpenMx

Comment on lines 101 to 140
```{r, include=FALSE}
if (!requireNamespace("OpenMx", quietly = TRUE)) {
# if OpenMx isn't available
n_subjects <- 500
df_summary_data <- data.frame(
age_mean = 34.45,
age_sd = 10.12345,
ht1_mean = 1.662,
ht1_sd = 0.0896277,
ht2_mean = 1.694,
ht2_sd = 0.09903498
)
set.seed(12345)
twinData <- data.frame(
ht1 = rnorm(n_subjects, mean = df_summary_data$ht1_mean, sd = df_summary_data$ht1_sd),
zyg = rep(c(1, 3), each = n_subjects / 2)
)
twinData$ht2 <- twinData$ht1 * ifelse(twinData$zyg == 1, 1, 0.5) +
rnorm(n_subjects, mean = 0, sd = df_summary_data$ht2_sd) + .1*rnorm(n_subjects, mean = df_summary_data$ht2_mean, sd = df_summary_data$ht2_sd)
twinData$ht2[twinData$zyg == 3] <- twinData$ht2[twinData$zyg == 3] + .5*rnorm(sum(twinData$zyg == 3), mean = df_summary_data$ht2_mean, sd = df_summary_data$ht2_sd)
} else {
data(twinData, package = "OpenMx")
require(dplyr)
# require(purrr)
selVars <- c("ht1", "ht2")
mzdzData <- subset(
twinData, zyg %in% c(1, 3),
c(selVars, "zyg")
)
mzdzData$RCoef <- c(1, NA, .5)[mzdzData$zyg]
mzData <- mzdzData %>% filter(zyg == 1)
}
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The data preparation logic in the include=FALSE chunk only defines selVars, mzdzData, and mzData when OpenMx IS available (inside the else block at lines 123-140). When OpenMx is NOT available, only twinData is created but selVars, mzdzData, and mzData are never defined. This will cause errors in subsequent code chunks that reference these variables (lines 164-177 and 182-195). The data preparation steps should be moved outside the conditional or duplicated in both branches.

Copilot uses AI. Check for mistakes.
smasongarrison and others added 3 commits January 7, 2026 10:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Streamlined and clarified the data preparation steps for the twin modeling example in v1_modelingvariancecomponents.Rmd. Moved and consolidated code blocks for loading and filtering data, and ensured consistent use of dplyr. Updated the corresponding HTML output.
@smasongarrison smasongarrison merged commit f65b27f into main Jan 7, 2026
12 checks passed
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