From 326dc2fa339ef721f85529cdbef3716002695609 Mon Sep 17 00:00:00 2001 From: James Hollway Date: Fri, 19 Jul 2024 09:33:44 +0200 Subject: [PATCH 1/7] Updated title to Title Case --- DESCRIPTION | 6 +++--- NEWS.md | 8 ++++++++ cran-comments.md | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index afd0d4c4..e882053d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: migraph -Title: Univariate and multivariate tests for multimodal and other networks -Version: 1.4.0 -Date: 2024-07-18 +Title: Univariate and Multivariate Tests for Multimodal and Other Networks +Version: 1.4.1 +Date: 2024-07-19 Description: A set of tools for testing networks. It includes functions for univariate and multivariate conditional uniform graph and quadratic assignment procedure testing, diff --git a/NEWS.md b/NEWS.md index 99b80fbb..6cbb28e8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +# migraph 1.4.1 + +2024-07-19 + +## Package + +- Made package title Title Case in DESCRIPTION + # migraph 1.4.0 2024-07-18 diff --git a/cran-comments.md b/cran-comments.md index e46ec175..4e11fbf3 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -11,5 +11,7 @@ * This release is expected to create errors with older versions of manynet, but should create no errors with the latest version +* Currently binaries of manynet have been built for most flavors, with the exception of r-release-windows-x86_66 +* There is expected to be test errors for this flavor until a manynet binary for v1.0.1 has been built * Since manynet is a Depends for migraph, this should not pose a problem for users upgrading From a07a296ed23514a7db127d43c875fff92e06a3fb Mon Sep 17 00:00:00 2001 From: James Hollway Date: Fri, 19 Jul 2024 10:57:35 +0200 Subject: [PATCH 2/7] network_reg now an alias for more consistent net_regression() --- R/model_regression.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/R/model_regression.R b/R/model_regression.R index a79e54b0..9edadfae 100644 --- a/R/model_regression.R +++ b/R/model_regression.R @@ -86,14 +86,14 @@ #' #' @examples #' networkers <- ison_networkers %>% to_subgraph(Discipline == "Sociology") -#' model1 <- network_reg(weight ~ alter(Citations) + sim(Citations), +#' model1 <- net_regression(weight ~ ego(Citations) + alter(Citations) + sim(Citations), #' networkers, times = 20) #' # Should be run many more `times` for publication-ready results #' tidy(model1) #' glance(model1) #' plot(model1) #' @export -network_reg <- function(formula, .data, +net_regression <- function(formula, .data, method = c("qap","qapy"), times = 1000, strategy = "sequential", @@ -242,6 +242,10 @@ network_reg <- function(formula, .data, } +# alias for the above +#' @export +network_reg <- net_regression + ################### gettval <- function(x, y, tol) { From 0032166b4654c1d0ed64aca2f2f50d58b4f5a81b Mon Sep 17 00:00:00 2001 From: James Hollway Date: Fri, 19 Jul 2024 11:37:07 +0200 Subject: [PATCH 3/7] Deprecating network_reg() in favour of net_regression() --- R/migraph-defunct.R | 13 +++++++++++++ R/model_regression.R | 4 ---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/R/migraph-defunct.R b/R/migraph-defunct.R index f46e4284..5c07dcd9 100644 --- a/R/migraph-defunct.R +++ b/R/migraph-defunct.R @@ -18,3 +18,16 @@ test_gof <- function(diff_model, diff_models) { old = "test_gof") test_fit(diff_model, diff_models) } + +#' @describeIn defunct Deprecated on 2024-07-19. +#' @export +network_reg <- function(formula, .data, + method = c("qap","qapy"), + times = 1000, + strategy = "sequential", + verbose = FALSE) { + .Deprecated("net_regression", package = "migraph", + old = "network_reg") + net_regression(formula, .data, method, times, + strategy, verbose) +} diff --git a/R/model_regression.R b/R/model_regression.R index 9edadfae..0ba0109e 100644 --- a/R/model_regression.R +++ b/R/model_regression.R @@ -242,10 +242,6 @@ net_regression <- function(formula, .data, } -# alias for the above -#' @export -network_reg <- net_regression - ################### gettval <- function(x, y, tol) { From 688d65d001d1f4165aab3c708f53666d42522d84 Mon Sep 17 00:00:00 2001 From: James Hollway Date: Fri, 19 Jul 2024 11:44:24 +0200 Subject: [PATCH 4/7] Refactored several functions to avoid tidyr dependency for pivot_longer and pivot_wider --- DESCRIPTION | 1 - R/class_models.R | 22 ++++++++++++++++++---- R/model_tests.R | 9 ++++----- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e882053d..3023e26a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,7 +32,6 @@ Imports: furrr, purrr, tidygraph, - tidyr Suggests: concaveman, covr, diff --git a/R/class_models.R b/R/class_models.R index c6cd8dcc..a8e24562 100644 --- a/R/class_models.R +++ b/R/class_models.R @@ -138,8 +138,15 @@ plot.netlm <- function(x, ...){ distrib <- as.data.frame(distrib) names(distrib) <- x$names distrib$obs <- seq_len(nrow(distrib)) - distrib <- tidyr::pivot_longer(distrib, - cols = 1:(ncol(distrib)-1)) + distrib <- stats::reshape(data = distrib, # tidyr::pivot_longer replacement + direction = "long", + varying = colnames(distrib)[-ncol(distrib)], + v.names = "value", + times = colnames(distrib)[-ncol(distrib)], + timevar = "name") + rownames(distrib) <- NULL + distrib$id <- NULL + distrib <- dplyr::arrange(distrib, obs) distrib$coef <- rep(unname(x$coefficients), nrow(x$dist)) distrib$tstat <- rep(unname(x$tstat), nrow(x$dist)) distrib$name <- factor(distrib$name, x$names) @@ -158,8 +165,15 @@ plot.netlogit <- function(x, ...){ distrib <- as.data.frame(distrib) names(distrib) <- x$names distrib$obs <- seq_len(nrow(distrib)) - distrib <- tidyr::pivot_longer(distrib, - cols = 1:(ncol(distrib)-1)) + distrib <- stats::reshape(data = distrib, # tidyr::pivot_longer replacement + direction = "long", + varying = colnames(distrib)[-ncol(distrib)], + v.names = "value", + times = colnames(distrib)[-ncol(distrib)], + timevar = "name") + rownames(distrib) <- NULL + distrib$id <- NULL + distrib <- dplyr::arrange(distrib, obs) distrib$coef <- rep(unname(x$coefficients), nrow(x$dist)) distrib$tstat <- rep(unname(x$tstat), nrow(x$dist)) distrib$name <- factor(distrib$name, x$names) diff --git a/R/model_tests.R b/R/model_tests.R index 29133a28..b32252f1 100644 --- a/R/model_tests.R +++ b/R/model_tests.R @@ -34,7 +34,6 @@ test_random <- function(.data, FUN, ..., times = 1000, strategy = "sequential", verbose = FALSE){ - if(missing(.data)) {expect_nodes(); .data <- .G()} args <- unlist(list(...)) if (!is.null(args)) { obsd <- FUN(.data, args) @@ -71,6 +70,7 @@ test_random <- function(.data, FUN, ..., class(out) <- "network_test" out } + #' @rdname tests #' @examples #' # (qaptest <- test_permutation(marvel_friends, @@ -82,7 +82,6 @@ test_permutation <- function(.data, FUN, ..., times = 1000, strategy = "sequential", verbose = FALSE){ - if(missing(.data)) {expect_nodes(); .data <- .G()} args <- unlist(list(...)) if (!is.null(args)) { obsd <- FUN(.data, args) @@ -231,9 +230,8 @@ test_fit <- function(diff_model, diff_models){ # make into method? x <- diff_model y <- diff_models sim <- `0` <- NULL - sims <- y |> dplyr::select(sim, t, I) |> - tidyr::pivot_wider(names_from = t, values_from = I) |> - dplyr::select(-c(sim, `0`)) + sims <- y |> dplyr::select(sim, t, I) + sims <- as.data.frame.matrix(stats::xtabs(I ~ sim + t, sims)) # tidyr::pivot_wider replacement sims <- sims[,colSums(stats::cov(sims))!=0] mah <- stats::mahalanobis(x$I[-1], colMeans(sims), stats::cov(sims)) pval <- pchisq(mah, df=length(x$I[-1]), lower.tail=FALSE) @@ -241,3 +239,4 @@ test_fit <- function(diff_model, diff_models){ # make into method? df = length(x$I[-1]), nobs = nrow(sims)) } + From d1890f0b2eb09841c0312051cb260dd79dd0bfbb Mon Sep 17 00:00:00 2001 From: James Hollway Date: Fri, 19 Jul 2024 11:46:54 +0200 Subject: [PATCH 5/7] Removed unnecessary reexports and dropped 6 Suggests and 3 Imports --- DESCRIPTION | 17 ++++--------- NAMESPACE | 23 +----------------- R/migraph-package.R | 2 +- R/reexports_classes.R | 56 ------------------------------------------- man/defunct.Rd | 12 ++++++++++ man/reexports.Rd | 17 ------------- man/regression.Rd | 6 ++--- 7 files changed, 21 insertions(+), 112 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3023e26a..84af80ed 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,24 +24,15 @@ Depends: manynet Imports: dplyr (>= 1.1.0), - generics, - ggplot2, - igraph (>= 1.5.0), - network, future, furrr, - purrr, - tidygraph, + generics, + ggplot2, + purrr Suggests: - concaveman, covr, - ggdendro, - minMSE, - oaqc, roxygen2, - rsconnect, - testthat, - xml2 + testthat Authors@R: c(person(given = "James", family = "Hollway", diff --git a/NAMESPACE b/NAMESPACE index 9177352f..073ce071 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,24 +9,15 @@ S3method(print,network_test) S3method(tidy,netlm) S3method(tidy,netlogit) export("%>%") -export(.E) -export(.G) -export(.N) export(aes) -export(as.network) -export(bind_edges) export(ggplot) export(ggsave) export(ggtitle) export(glance) export(guides) -export(is.network) -export(is.tbl_graph) -export(is_igraph) export(labs) -export(mutate) +export(net_regression) export(network_reg) -export(rename) export(scale_y_discrete) export(test_distribution) export(test_fit) @@ -34,7 +25,6 @@ export(test_gof) export(test_permutation) export(test_random) export(tidy) -export(with_graph) export(xlab) export(ylab) importFrom(dplyr,"%>%") @@ -54,13 +44,10 @@ importFrom(ggplot2,labs) importFrom(ggplot2,scale_y_discrete) importFrom(ggplot2,xlab) importFrom(ggplot2,ylab) -importFrom(igraph,is_igraph) importFrom(manynet,bind_node_attributes) importFrom(manynet,generate_random) importFrom(manynet,is_complex) importFrom(manynet,is_directed) -importFrom(network,as.network) -importFrom(network,is.network) importFrom(purrr,flatten) importFrom(stats,as.formula) importFrom(stats,binomial) @@ -68,11 +55,3 @@ importFrom(stats,df.residual) importFrom(stats,glm.fit) importFrom(stats,pchisq) importFrom(stats,quantile) -importFrom(tidygraph,.E) -importFrom(tidygraph,.G) -importFrom(tidygraph,.N) -importFrom(tidygraph,bind_edges) -importFrom(tidygraph,is.tbl_graph) -importFrom(tidygraph,mutate) -importFrom(tidygraph,rename) -importFrom(tidygraph,with_graph) diff --git a/R/migraph-package.R b/R/migraph-package.R index 4d78ffe7..e97167ee 100644 --- a/R/migraph-package.R +++ b/R/migraph-package.R @@ -18,4 +18,4 @@ thisRequires <- function(pkgname){ } # defining global variables more centrally -utils::globalVariables(c(".data", ".graph_context")) \ No newline at end of file +utils::globalVariables(c(".data", "obs")) \ No newline at end of file diff --git a/R/reexports_classes.R b/R/reexports_classes.R index 534e7452..92333503 100644 --- a/R/reexports_classes.R +++ b/R/reexports_classes.R @@ -1,61 +1,5 @@ -#' @importFrom igraph is_igraph -#' @export -igraph::is_igraph - -#' @importFrom network is.network -#' @export -network::is.network - -#' @importFrom network as.network -#' @export -network::as.network - #' @importFrom dplyr %>% #' @export dplyr::`%>%` -#' @importFrom tidygraph with_graph -#' @export -tidygraph::with_graph - -#' @importFrom tidygraph is.tbl_graph -#' @export -tidygraph::is.tbl_graph - -#' @importFrom tidygraph .G -#' @export -tidygraph::.G - -#' @importFrom tidygraph .N -#' @export -tidygraph::.N - -#' @importFrom tidygraph .E -#' @export -tidygraph::.E - -#' @importFrom tidygraph mutate -#' @export -tidygraph::mutate - -#' @importFrom tidygraph rename -#' @export -tidygraph::rename - -#' @importFrom tidygraph bind_edges -#' @export -tidygraph::bind_edges - -expect_nodes <- function() { - if (!.graph_context$free() && .graph_context$active() != "nodes") { - stop("This call requires nodes to be active", call. = FALSE) - } -} - -expect_edges <- function() { - if (!.graph_context$free() && .graph_context$active() != "edges") { - stop("This call requires edges to be active", call. = FALSE) - } -} - # #' @importFrom rlang `%||%` diff --git a/man/defunct.Rd b/man/defunct.Rd index 359fd939..1afb7304 100644 --- a/man/defunct.Rd +++ b/man/defunct.Rd @@ -3,9 +3,19 @@ \name{defunct} \alias{defunct} \alias{test_gof} +\alias{network_reg} \title{Functions that have been renamed, superseded, or are no longer working} \usage{ test_gof(diff_model, diff_models) + +network_reg( + formula, + .data, + method = c("qap", "qapy"), + times = 1000, + strategy = "sequential", + verbose = FALSE +) } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} @@ -20,5 +30,7 @@ wherever possible and update your scripts accordingly. \itemize{ \item \code{test_gof()}: Deprecated on 2024-06-16. +\item \code{network_reg()}: Deprecated on 2024-07-19. + }} \keyword{internal} diff --git a/man/reexports.Rd b/man/reexports.Rd index 9969dad8..34dd94df 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -6,18 +6,7 @@ \alias{reexports} \alias{tidy} \alias{glance} -\alias{is_igraph} -\alias{is.network} -\alias{as.network} \alias{\%>\%} -\alias{with_graph} -\alias{is.tbl_graph} -\alias{.G} -\alias{.N} -\alias{.E} -\alias{mutate} -\alias{rename} -\alias{bind_edges} \alias{ggplot} \alias{ggtitle} \alias{guides} @@ -39,11 +28,5 @@ below to see their documentation. \item{generics}{\code{\link[generics]{glance}}, \code{\link[generics]{tidy}}} \item{ggplot2}{\code{\link[ggplot2]{aes}}, \code{\link[ggplot2]{ggplot}}, \code{\link[ggplot2]{ggsave}}, \code{\link[ggplot2:labs]{ggtitle}}, \code{\link[ggplot2]{guides}}, \code{\link[ggplot2]{labs}}, \code{\link[ggplot2:scale_discrete]{scale_y_discrete}}, \code{\link[ggplot2:labs]{xlab}}, \code{\link[ggplot2:labs]{ylab}}} - - \item{igraph}{\code{\link[igraph]{is_igraph}}} - - \item{network}{\code{\link[network:network]{as.network}}, \code{\link[network:network]{is.network}}} - - \item{tidygraph}{\code{\link[tidygraph:context_accessors]{.E}}, \code{\link[tidygraph:context_accessors]{.G}}, \code{\link[tidygraph:context_accessors]{.N}}, \code{\link[tidygraph:bind_graphs]{bind_edges}}, \code{\link[tidygraph:tbl_graph]{is.tbl_graph}}, \code{\link[tidygraph:reexports]{mutate}}, \code{\link[tidygraph:reexports]{rename}}, \code{\link[tidygraph]{with_graph}}} }} diff --git a/man/regression.Rd b/man/regression.Rd index 5b232f9e..ddd33bd0 100644 --- a/man/regression.Rd +++ b/man/regression.Rd @@ -2,10 +2,10 @@ % Please edit documentation in R/model_regression.R \name{regression} \alias{regression} -\alias{network_reg} +\alias{net_regression} \title{Linear and logistic regression for network data} \usage{ -network_reg( +net_regression( formula, .data, method = c("qap", "qapy"), @@ -94,7 +94,7 @@ will always be respected in permutations and analysis. } \examples{ networkers <- ison_networkers \%>\% to_subgraph(Discipline == "Sociology") -model1 <- network_reg(weight ~ alter(Citations) + sim(Citations), +model1 <- net_regression(weight ~ ego(Citations) + alter(Citations) + sim(Citations), networkers, times = 20) # Should be run many more `times` for publication-ready results tidy(model1) From dbe343d6d1f855a75ad0bc74cdbe6b7c8066c270 Mon Sep 17 00:00:00 2001 From: James Hollway Date: Fri, 19 Jul 2024 11:47:32 +0200 Subject: [PATCH 6/7] Added alttext and CRAN link to website --- pkgdown/_pkgdown.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index bf1227cf..3aefcb3d 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -17,10 +17,12 @@ navbar: right: - search - github + - cran components: home: icon: fa-home fa-lg href: index.html + aria-label: Go to home reference: text: Function Overview href: reference/index.html @@ -30,6 +32,11 @@ navbar: github: icon: "fab fa-github fa-lg" href: https://github.com/stocnet/migraph + aria-label: View on Github + cran: + icon: "fab fa-r-project" + href: https://cloud.r-project.org/package=migraph + aria-label: View on CRAN reference: - title: "Models" desc: "Functions for modelling multimodal networks:" From 0b013c6f36b0c576ca474c86117ace2226c008ce Mon Sep 17 00:00:00 2001 From: James Hollway Date: Fri, 19 Jul 2024 11:51:14 +0200 Subject: [PATCH 7/7] Updated NEWS --- NEWS.md | 10 ++++++++++ man/migraph-package.Rd | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 6cbb28e8..5fdedf3a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,16 @@ ## Package - Made package title Title Case in DESCRIPTION +- Added alttext to icons used in pkgdown site +- Added CRAN link in pkgdown site +- Removed unnecessary reexports +- Dropped 6 Suggests dependencies +- Dropped 4 Imports dependencies (including `{tidyr}`, see below) + +## Models + +- `network_reg()` renamed to `net_regression()` for consistency +- Refactored several functions to avoid `{tidyr}` dependency for pivoting longer and wider # migraph 1.4.0 diff --git a/man/migraph-package.Rd b/man/migraph-package.Rd index d0f9c796..37bac9d0 100644 --- a/man/migraph-package.Rd +++ b/man/migraph-package.Rd @@ -4,7 +4,7 @@ \name{migraph-package} \alias{migraph} \alias{migraph-package} -\title{migraph: Univariate and multivariate tests for multimodal and other networks} +\title{migraph: Univariate and Multivariate Tests for Multimodal and Other Networks} \description{ \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}}