diff --git a/cran-comments.md b/cran-comments.md index 922643ca..fbd7861c 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,13 +1,13 @@ # Description -This update includes minor enhancements and bug fixes related to how string ids are handled in various functions. +This update includes minor enhancements and bug fixes related to how string ids are handled in various functions. It also now allows certain vignettes to not throw an error if openmx is not installed for older R versions. This should resolve r-oldrel-windows-x86_64 1.5.0 22.00 246.00 268.00 ERROR seen in the last CRAN check. # Test Environments 1. Local OS: Windows 11 x64 (build 26220), R 4.5.2 (2025-10-31 ucrt) 2. **GitHub Actions**: - - [Link](https://github.com/R-Computing-Lab/BGmisc/actions/runs/20666823859) + - [Link](https://github.com/R-Computing-Lab/BGmisc/actions/runs/20786177599) - macOS (latest version) with the latest R release. - Windows (latest version) with the latest R release. - Ubuntu (latest version) with: diff --git a/vignettes/v1_modelingvariancecomponents.Rmd b/vignettes/v1_modelingvariancecomponents.Rmd index c82441a9..479c2e40 100644 --- a/vignettes/v1_modelingvariancecomponents.Rmd +++ b/vignettes/v1_modelingvariancecomponents.Rmd @@ -24,8 +24,18 @@ This vignette provides a detailed guide to specific functions within the `BGmisc ```{r setup, include=FALSE} library(BGmisc) -require(EasyMx) -require(OpenMx) +if (!requireNamespace("EasyMx", quietly = TRUE)) { + message("Please install EasyMx to run the model fitting examples.") +} else { + require(EasyMx) +} +if (!requireNamespace("OpenMx", quietly = TRUE)) { +message("Please install OpenMx to run the model fitting examples.") +} else { + require(OpenMx) +} + + ``` Ensure that the `BGmisc` package is installed and loaded. @@ -37,7 +47,7 @@ Ensure that the following dependencies are installed before proceeding as they p - `OpenMx` -```{r} +```r library(BGmisc) library(EasyMx) library(OpenMx) @@ -88,11 +98,40 @@ identifyComponentModel( As you can see the model is identified, now that we've added another group. Let us confirm by fitting a model. First we prepare the data. -```{r} +```{r, include=FALSE} +if (!requireNamespace("OpenMx", quietly = TRUE)) { + # if OpenMx isn't available + n_subjects <- 500 require(dplyr) -# require(purrr) + 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") +} + +``` + +```{r} +require(dplyr) + + selVars <- c("ht1", "ht2") mzdzData <- subset( @@ -104,11 +143,16 @@ mzdzData$RCoef <- c(1, NA, .5)[mzdzData$zyg] mzData <- mzdzData %>% filter(zyg == 1) + ``` + Let us fit the data with MZ twins by themselves. ```{r} +if (!requireNamespace("EasyMx", quietly = TRUE)) { + print("Please install EasyMx to run the model fitting examples.") +} else { run1 <- emxTwinModel( model = "Cholesky", relatedness = "RCoef", @@ -118,11 +162,15 @@ run1 <- emxTwinModel( ) summary(run1) +} ``` As you can see the model was unsuccessful because it was not identified. But when we add another group, so that the model is identified, the model now fits. ```{r} +if (!requireNamespace("EasyMx", quietly = TRUE)) { + print("Please install EasyMx to run the model fitting examples.") +} else { run2 <- emxTwinModel( model = "Cholesky", relatedness = "RCoef", @@ -132,4 +180,5 @@ run2 <- emxTwinModel( ) summary(run2) +} ``` diff --git a/vignettes/v1_modelingvariancecomponents.html b/vignettes/v1_modelingvariancecomponents.html index 23d7abfd..3060a1e0 100644 --- a/vignettes/v1_modelingvariancecomponents.html +++ b/vignettes/v1_modelingvariancecomponents.html @@ -48,8 +48,9 @@ }