-
Notifications
You must be signed in to change notification settings - Fork 3
Improve vignette compatibility for missing OpenMx #108
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
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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 |
| ```{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) | ||
| } |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
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.
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.
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.