From e337c9cebfbd2e97a3ca397fe7ef5700f125e950 Mon Sep 17 00:00:00 2001 From: James Hollway Date: Tue, 23 Jun 2026 13:00:23 +0200 Subject: [PATCH 1/2] Improved goodpractices --- DESCRIPTION | 9 ++++----- NEWS.md | 8 ++++++++ R/class_makes.R | 2 ++ R/class_models.R | 2 ++ R/model_tests.R | 1 + inst/tutorials/tutorial0/tutorial0.Rmd | 9 ++++++--- inst/tutorials/tutorial8/diversity.Rmd | 2 +- inst/tutorials/tutorial9/ergm.Rmd | 10 +++++----- tests/testthat/test-model_tests.R | 8 ++++---- 9 files changed, 33 insertions(+), 18 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index be7276cb..378f8133 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,10 +1,9 @@ Package: migraph Title: Inferential Methods for Multimodal and Other Networks -Version: 1.6.5 +Version: 1.6.6 Description: A set of tools for testing networks. - It includes functions for univariate and multivariate - conditional uniform graph and quadratic assignment procedure testing, - and network regression. + It includes functions for univariate and multivariate conditional uniform graph + and quadratic assignment procedure testing, and network regression. The package is a complement to 'Multimodal Political Networks' (2021, ISBN:9781108985000), and includes various datasets used in the book. @@ -20,7 +19,7 @@ LazyData: true Depends: R (>= 4.1.0), manynet (>= 2.1.2), - autograph (>= 0.4.0), + autograph (>= 1.0.0), netrics (>= 0.3.1) Imports: dplyr (>= 1.1.0), diff --git a/NEWS.md b/NEWS.md index c5b81c4b..38b42453 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +# migraph 1.6.6 + +2026-06-23 + +## Package + +- Improved goodpractices + # migraph 1.6.5 2026-06-22 diff --git a/R/class_makes.R b/R/class_makes.R index ee8cf741..95478c59 100644 --- a/R/class_makes.R +++ b/R/class_makes.R @@ -24,6 +24,7 @@ print.diffs_model <- function(x, ...){ x <- x[,colSums(x, na.rm=TRUE) != 0] x$I_new <- NULL print(dplyr::tibble(x, ...)) + invisible(x) } ## Over #### @@ -37,6 +38,7 @@ make_over_memb <- function(out, categ) { #' @export print.over_memb <- function(x, ...){ print(round(unclass(x),3), ...) + invisible(x) } diff --git a/R/class_models.R b/R/class_models.R index d5644813..13a82ddb 100644 --- a/R/class_models.R +++ b/R/class_models.R @@ -266,6 +266,7 @@ print.netlm <- function(x, ...){ print(tidy(x)) cat("\n# Model summary statistics\n") print(glance(x)) + invisible(x) } #' @export @@ -274,6 +275,7 @@ print.netlogit <- function(x, ...){ print(tidy(x)) cat("\n# Model summary statistics\n") print(glance(x)) + invisible(x) } # Unused because infinite recursion through summary.ergm() in tidy.ergm() diff --git a/R/model_tests.R b/R/model_tests.R index f7ebf75f..0258164c 100644 --- a/R/model_tests.R +++ b/R/model_tests.R @@ -172,5 +172,6 @@ print.network_test <- function(x, ..., cat("Observed Value:", x$testval, "\n") cat("Pr(X>=Obs):", x$pgteobs, "\n") cat("Pr(X<=Obs):", x$plteobs, "\n\n") + invisible(x) } diff --git a/inst/tutorials/tutorial0/tutorial0.Rmd b/inst/tutorials/tutorial0/tutorial0.Rmd index d97cc8ea..8fc173a8 100644 --- a/inst/tutorials/tutorial0/tutorial0.Rmd +++ b/inst/tutorials/tutorial0/tutorial0.Rmd @@ -171,7 +171,8 @@ surname <- "Hollway" y.chromosome <- T # or TRUE siblings <- 1 age <- NA # This is used for missing information -# Note that these objects then appear in RStudio's environment pane (by default the top right) +# Note that these objects then appear in RStudio's environment pane +# (by default the top right) ``` You can then recover this information by simply calling these objects: @@ -214,7 +215,8 @@ teenageqrtrs <- seq(13, 19.99, by = 0.25) # We can recall every third value from this object using a repeating vector teenageqrtrs teenageqrtrs[c(FALSE, FALSE, TRUE)] -# teenageqrtrs[c(F, F, T)] # Also works but it is best practice to write out the logic. +# teenageqrtrs[c(F, F, T)] +# Also works but it is best practice to write out the logic. ``` So R can help us store and recall values and even vectors of values, @@ -327,7 +329,8 @@ mylist$Siblings <- c(1, NA) # Now you can add the others from above You can also add lists to a list: ```{r list-nest, exercise = TRUE, exercise.setup="list-names"} -mylist$Lived <- list(c("New Zealand", "UK", "New Zealand", "Germany", "UK", "Switzerland"), NA) +mylist$Lived <- list(c("New Zealand", "UK", "New Zealand", + "Germany", "UK", "Switzerland"), NA) ``` Note that we've been using parentheses, `()`, here and not brackets, `[]`, diff --git a/inst/tutorials/tutorial8/diversity.Rmd b/inst/tutorials/tutorial8/diversity.Rmd index a9d3b1f9..380a7492 100644 --- a/inst/tutorials/tutorial8/diversity.Rmd +++ b/inst/tutorials/tutorial8/diversity.Rmd @@ -49,7 +49,7 @@ learnr::random_phrases_add(language = "en", "Beau travail!", "Bravo!", "Super!"), - encouragement = c("Bon effort")) + encouragement = "Bon effort") marvel_friends <- to_unsigned(to_uniplex(fict_marvel, "relationship"), keep = "positive") marvel_friends <- to_giant(marvel_friends) marvel_friends <- marvel_friends %>% to_subgraph(Appearances >= mean(Appearances)) diff --git a/inst/tutorials/tutorial9/ergm.Rmd b/inst/tutorials/tutorial9/ergm.Rmd index cf7d196b..cd35cd46 100644 --- a/inst/tutorials/tutorial9/ergm.Rmd +++ b/inst/tutorials/tutorial9/ergm.Rmd @@ -54,7 +54,7 @@ learnr::random_phrases_add(language = "en", "Beau travail!", "Bravo!", "Super!"), - encouragement = c("Bon effort")) + encouragement = "Bon effort") ``` ## This tutorial @@ -282,10 +282,10 @@ how much change there is depends critically on “where you are on the curve”. ```{r predprobplot, echo = F, fig.height=3, fig.width=8, purl = FALSE} ggplot(data.frame(x = c(-4, 4)), aes(x = x)) + ggplot2::stat_function(fun = plogis, colour = "blue") + - ggplot2::geom_line(aes(x = 0, y=c(.5,.73), colour = "+1 unit change @0")) + - ggplot2::geom_line(aes(x = c(0,1), y=.73, colour = "+1 unit change @0")) + - ggplot2::geom_line(aes(x = 1, y=c(.73,.88), colour = "+1 unit change @1")) + - ggplot2::geom_line(aes(x = c(1,2), y=.88, colour = "+1 unit change @1")) + + ggplot2::geom_line(aes(x = 0, y=c(0.5,.73), colour = "+1 unit change @0")) + + ggplot2::geom_line(aes(x = c(0,1), y=0.73, colour = "+1 unit change @0")) + + ggplot2::geom_line(aes(x = 1, y=c(0.73,0.88), colour = "+1 unit change @1")) + + ggplot2::geom_line(aes(x = c(1,2), y=0.88, colour = "+1 unit change @1")) + ggplot2::theme_minimal() ``` diff --git a/tests/testthat/test-model_tests.R b/tests/testthat/test-model_tests.R index 426e7f37..7ab79e6d 100644 --- a/tests/testthat/test-model_tests.R +++ b/tests/testthat/test-model_tests.R @@ -17,7 +17,7 @@ test_that("test_random works", { # Set the cugtest up # Test stuff cug1 expect_equal(as.numeric(cugtest$testval), -0.85714, tolerance = 0.001) - expect_equal(length(cugtest$testdist), 200) # NB: Stochastic + expect_length(cugtest$testdist, 200) # NB: Stochastic expect_false(cugtest$mode) expect_false(cugtest$diag) expect_equal(cugtest$cmode, "edges") @@ -28,7 +28,7 @@ test_that("test_random works", { # Test stuff cug2 expect_equal(as.numeric(cugtest2$testval), 0.2375, tolerance = 0.001) # expect_equal(mean(cugtest3$testdist), 0.3600, tolerance = 0.02) - expect_equal(length(cugtest2$testdist), 200) # NB: Stochastic + expect_length(cugtest2$testdist, 200) # NB: Stochastic expect_false(cugtest2$mode) expect_false(cugtest2$diag) expect_equal(cugtest2$cmode, "edges") @@ -46,9 +46,9 @@ qaptest <- test_permutation(marvel_friends, test_that("test_permutation works", { expect_equal(as.numeric(qaptest$testval), -0.85714, tolerance = 0.001) - expect_equal(length(qaptest$testdist), 200) # NB: Stochastic expect_equal(class(qaptest$plteobs), "numeric") # NB: Stochastic expect_equal(class(qaptest$pgteobs), "numeric") # NB: Stochastic + expect_length(qaptest$testdist, 200) # NB: Stochastic expect_equal(qaptest$reps, 200) expect_s3_class(qaptest, "network_test") }) @@ -62,9 +62,9 @@ test_that("test_configuration works", { times = 200) expect_s3_class(configtest, "network_test") expect_equal(as.numeric(configtest$testval), -0.85714, tolerance = 0.001) - expect_equal(length(configtest$testdist), 200) # NB: Stochastic expect_equal(class(configtest$plteobs), "numeric") # NB: Stochastic expect_equal(class(configtest$pgteobs), "numeric") # NB: Stochastic + expect_length(configtest$testdist, 200) # NB: Stochastic }) From 3531ebadbaf0d93d78d4af18c751e115a967634a Mon Sep 17 00:00:00 2001 From: James Hollway Date: Tue, 23 Jun 2026 13:00:38 +0200 Subject: [PATCH 2/2] Dropped netrics tutorial testing --- NEWS.md | 1 + cran-comments.md | 4 ++++ tests/testthat/test-tutorials_netrics.R | 13 ------------- 3 files changed, 5 insertions(+), 13 deletions(-) delete mode 100644 tests/testthat/test-tutorials_netrics.R diff --git a/NEWS.md b/NEWS.md index 38b42453..096712b3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ ## Package - Improved goodpractices +- Dropped netrics tutorial testing # migraph 1.6.5 diff --git a/cran-comments.md b/cran-comments.md index c9adac43..b264e339 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -11,3 +11,7 @@ - Updated manynet dependency to 1.2.1 to fix reverse dependency issue - Updated netrics dependency to 0.3.1 to fix reverse dependency issue +- Checked with CRAN versions of dependencies + - Only issue was CRAN versions of manynet and netrics built under R v4.6.1, + whereas this package was built locally under R v4.6.0, + though this should not be a problem for CRAN submission. diff --git a/tests/testthat/test-tutorials_netrics.R b/tests/testthat/test-tutorials_netrics.R deleted file mode 100644 index 0140489b..00000000 --- a/tests/testthat/test-tutorials_netrics.R +++ /dev/null @@ -1,13 +0,0 @@ -# test_that("netrics tutorials work", { -# for(tute in find_pkg_tutorial_paths("netrics")){ -# expect_null(check_tute_rendering(tute)) -# } -# }) - -test_that("netrics tutorial code runs without warnings or errors", { - skip_if_not_installed("netrics", minimum_version = "0.2.2") - for(tute in find_pkg_tutorial_paths("netrics")){ - expect_null(check_tute_functions(tute), - info = paste("Error in tutorial", basename(tute))) - } -}) \ No newline at end of file