diff --git a/DESCRIPTION b/DESCRIPTION index 7726e204..886afeca 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,7 @@ Package: manynet -Title: Many Ways to Make, Modify, Mark, and Measure Myriad Networks -Version: 2.1.1 -Description: Many tools for making, modifying, marking, measuring, - and motifs and memberships of many different types of networks. +Title: Many Ways to Make, Manipulate, and Modify Myriad Networks +Version: 2.1.2 +Description: Many tools for making, manipulating, and modifying many different types of networks. All functions operate with matrices, edge lists, and 'igraph', 'network', and 'tidygraph' objects, on directed, multiplex, multimodal, signed, and other networks. The package includes functions for importing and exporting, creating and generating networks, diff --git a/NAMESPACE b/NAMESPACE index a3dba39f..ea598489 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -117,6 +117,7 @@ S3method(as_tidygraph,siena) S3method(as_tidygraph,stocnet) S3method(as_tidygraph,tbl_graph) S3method(bind_changes,default) +S3method(bind_changes,igraph) S3method(bind_changes,stocnet) S3method(bind_changes,tbl_graph) S3method(bind_nodes,default) @@ -142,6 +143,8 @@ S3method(filter_nodes,default) S3method(filter_nodes,stocnet) S3method(filter_nodes,tbl_graph) S3method(filter_ties,default) +S3method(filter_ties,igraph) +S3method(filter_ties,stocnet) S3method(filter_ties,tbl_graph) S3method(from_ties,stocnet) S3method(from_ties,tbl_graph) @@ -394,6 +397,7 @@ S3method(to_components,matrix) S3method(to_components,network) S3method(to_components,tbl_graph) S3method(to_correlation,default) +S3method(to_correlation,matrix) S3method(to_correlation,tbl_graph) S3method(to_cosine,default) S3method(to_cosine,matrix) @@ -776,51 +780,11 @@ export(node_heterophily) export(node_hierarchy) export(node_homophily) export(node_hub) -export(node_in_adopter) -export(node_in_automorphic) -export(node_in_betweenness) -export(node_in_brokering) -export(node_in_community) -export(node_in_component) -export(node_in_core) -export(node_in_eigen) -export(node_in_equivalence) -export(node_in_fluid) -export(node_in_greedy) -export(node_in_infomap) -export(node_in_leiden) -export(node_in_louvain) -export(node_in_optimal) -export(node_in_partition) -export(node_in_regular) -export(node_in_roulette) -export(node_in_spinglass) -export(node_in_strong) -export(node_in_structural) -export(node_in_walktrap) -export(node_in_weak) export(node_indegree) export(node_induced) export(node_infomap) export(node_information) -export(node_is_core) -export(node_is_cutpoint) -export(node_is_exposed) -export(node_is_fold) -export(node_is_independent) -export(node_is_infected) -export(node_is_isolate) -export(node_is_latent) -export(node_is_max) -export(node_is_mean) -export(node_is_mentor) -export(node_is_min) export(node_is_mode) -export(node_is_neighbor) -export(node_is_pendant) -export(node_is_random) -export(node_is_recovered) -export(node_is_universal) export(node_kcoreness) export(node_kernighanlin) export(node_leading_eigen) @@ -904,21 +868,6 @@ export(tie_closeness) export(tie_cohesion) export(tie_degree) export(tie_eigenvector) -export(tie_is_bridge) -export(tie_is_cyclical) -export(tie_is_feedback) -export(tie_is_imbalanced) -export(tie_is_loop) -export(tie_is_max) -export(tie_is_min) -export(tie_is_multiple) -export(tie_is_path) -export(tie_is_random) -export(tie_is_reciprocated) -export(tie_is_simmelian) -export(tie_is_transitive) -export(tie_is_triangular) -export(tie_is_triplet) export(tie_is_twomode) export(tie_signs) export(tie_weights) diff --git a/NEWS.md b/NEWS.md index d04bda49..63d6f4fc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,33 @@ +# manynet 2.1.2 + +## Package + +- Updated title/description text +- Updated README + - Updated TOC to include new wrangling section + - Added package migration note to README +- Updated startup messages with migration notesand links to `{autograph}`, `{netrics}`, and `{migraph}` +- Removed a set of defunct wrappers for moved/retired functions + +## Making + +- Fixed reference formatting of DOI and citation text + +## Coercion + +- Improved `expect_nodes()`/`expect_ties()` and introduces internal active-context helpers +- Fixed `as_diffusion.igraph()` to derive diffusion events from changelists + +## Manipulating + +- Added `filter_ties.igraph()` and `filter_ties.stocnet()` +- Improved active context inference across `mutate_nodes.stocnet()`, `mutate_ties.stocnet()`, `filter_nodes.stocnet()`, and `filter_ties.stocnet()` +- Added `bind_changes.igraph()` and delegated 'tbl_graph' method to it + +## Modifying + +- Added `to_correlation.matrix()` S3 method + # manynet 2.1.1 ## Package diff --git a/R/coerce_graph.R b/R/coerce_graph.R index 87861341..a5771b59 100644 --- a/R/coerce_graph.R +++ b/R/coerce_graph.R @@ -846,6 +846,16 @@ as_diffusion.mnet <- function(.data, twomode = FALSE, events) { #' @export as_diffusion.igraph <- function(.data, twomode = FALSE, events) { net <- as_tidygraph(.data) + if (missing(events)) { + events <- as_changelist(.data) + } + events <- events |> + dplyr::filter(var == "diffusion") |> + dplyr::transmute( + t = time, + nodes = node, + event = value + ) event <- NULL sumchanges <- events |> dplyr::group_by(t) |> dplyr::reframe(I_new = sum(event == "I"), diff --git a/R/make_generate.R b/R/make_generate.R index d66af88f..ce174923 100644 --- a/R/make_generate.R +++ b/R/make_generate.R @@ -313,7 +313,7 @@ generate_smallworld <- function(n, p = 0.05, directed = FALSE, width = 2) { #' Barabasi, Albert-Laszlo, and Reka Albert. 1999. #' “Emergence of Scaling in Random Networks.” #' _Science_ 286(5439):509–12. -#' \doi{10.1126/science.286.5439.509}. +#' \doi{10.1126/science.286.5439.509} #' @examples #' generate_scalefree(12, 0.25) #' generate_scalefree(12, 1.25) @@ -348,8 +348,9 @@ generate_scalefree <- function(n, p = 1, directed = FALSE) { #' @references #' ## On the forest-fire model #' Leskovec, Jure, Jon Kleinberg, and Christos Faloutsos. 2007. -#' "\href{https://www.cs.cmu.edu/~jure/pubs/powergrowth-tkdd.pdf}{Graph evolution: Densification and shrinking diameters}". +#' "Graph evolution: Densification and shrinking diameters". #' _ACM transactions on Knowledge Discovery from Data_, 1(1): 2-es. +#' \doi{10.1145/1217299.1217301} #' @examples #' generate_fire(10) #' @export diff --git a/R/manip_changes.R b/R/manip_changes.R index 373b4a82..87ac4cd3 100644 --- a/R/manip_changes.R +++ b/R/manip_changes.R @@ -93,6 +93,11 @@ bind_changes.default <- function(.data, changes, var, ...){ #' @export bind_changes.tbl_graph <- function(.data, changes, var, ...){ + as_tidygraph(bind_changes.igraph(.data, changes, var, ...)) +} + +#' @export +bind_changes.igraph <- function(.data, changes, var, ...){ out <- .data if(length(names(changes)) == 4){ @@ -139,7 +144,7 @@ bind_changes.tbl_graph <- function(.data, changes, var, ...){ } igraph::graph_attr(out)$changes <- changes - as_tidygraph(out) + out } .check_changevars <- function(changes){ diff --git a/R/manip_nodes.R b/R/manip_nodes.R index 34da566f..39266c09 100644 --- a/R/manip_nodes.R +++ b/R/manip_nodes.R @@ -110,7 +110,8 @@ filter_nodes.tbl_graph <- function(.data, ..., .by = NULL){ #' @export filter_nodes.stocnet <- function(.data, ..., .by = NULL){ - if(is.null(.data$nodes) || nrow(.data$nodes) == 0) return(.data) + with_active_context(.data, "nodes", { + if(is.null(.data$nodes) || nrow(.data$nodes) == 0) return(.data) node_df <- dplyr::mutate(.data$nodes, .orig_id = dplyr::row_number()) kept_nodes <- dplyr::filter(node_df, ..., .by = dplyr::all_of(.by)) @@ -134,6 +135,7 @@ filter_nodes.stocnet <- function(.data, ..., .by = NULL){ make_stocnet(nodes = out_nodes, ties = out_ties, changes = out_changes, global = .data$global, info = .data$info) + }) } #' @rdname manip_nodes_num @@ -279,10 +281,13 @@ mutate_nodes.network <- function(.data, ...){ #' @export mutate_nodes.stocnet <- function(.data, ...){ - out <- .data - out$nodes <- out$nodes |> - dplyr::mutate(...) - out + with_active_context(.data, "nodes", { + if (is.null(.data$nodes) || nrow(.data$nodes) == 0) return(.data) + out <- .data + out$nodes <- out$nodes |> + dplyr::mutate(...) + out + }) } #' @rdname manip_nodes_attr diff --git a/R/manip_ties.R b/R/manip_ties.R index 74cef338..b046fd85 100644 --- a/R/manip_ties.R +++ b/R/manip_ties.R @@ -194,6 +194,14 @@ filter_ties.default <- function(.data, ...){ as_input(.data, filter_ties, ...) } +#' @export +filter_ties.igraph <- function(.data, ...){ + as_tidygraph(.data) |> tidygraph::activate(edges) |> + tidygraph::filter(...) |> + tidygraph::activate(nodes) |> + as_igraph() +} + #' @export filter_ties.tbl_graph <- function(.data, ...){ .data |> tidygraph::activate(edges) |> @@ -201,6 +209,16 @@ filter_ties.tbl_graph <- function(.data, ...){ tidygraph::activate(nodes) } +#' @export +filter_ties.stocnet <- function(.data, ...){ + with_active_context(.data, "edges", { + if (is.null(.data$ties) || nrow(.data$ties) == 0) return(.data) + out <- .data + out$ties <- out$ties |> dplyr::filter(...) + out + }) +} + # Manipulating ties attributes #### #' Manipulating tie attributes @@ -271,10 +289,13 @@ mutate_ties.tbl_graph <- function(.data, ...){ #' @export mutate_ties.stocnet <- function(.data, ...){ - out <- .data - out$ties <- out$ties |> - dplyr::mutate(...) - out + with_active_context(.data, "edges", { + if (is.null(.data$ties) || nrow(.data$ties) == 0) return(.data) + out <- .data + out$ties <- out$ties |> + dplyr::mutate(...) + out + }) } #' @rdname manip_ties_attr diff --git a/R/manynet-defunct.R b/R/manynet-defunct.R index 673d10bd..955e39e0 100644 --- a/R/manynet-defunct.R +++ b/R/manynet-defunct.R @@ -304,134 +304,6 @@ node_walktrap <- function(...) fn_moved("node_walktrap", "node_in_walktrap", ver #' @export node_weak_components <- function(...) fn_moved("node_weak_components", "node_in_weak", version = "2.0.0") -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_core <- function(...) fn_moved("node_is_core", "node_is_core", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_cutpoint <- function(...) fn_moved("node_is_cutpoint", "node_is_cutpoint", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_exposed <- function(...) fn_moved("node_is_exposed", "node_is_exposed", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_fold <- function(...) fn_moved("node_is_fold", "node_is_fold", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_independent <- function(...) fn_moved("node_is_independent", "node_is_independent", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_infected <- function(...) fn_moved("node_is_infected", "node_is_infected", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_isolate <- function(...) fn_moved("node_is_isolate", "node_is_isolate", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_latent <- function(...) fn_moved("node_is_latent", "node_is_latent", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_max <- function(...) fn_moved("node_is_max", "node_is_max", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_mean <- function(...) fn_moved("node_is_mean", "node_is_mean", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_mentor <- function(...) fn_moved("node_is_mentor", "node_is_mentor", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_min <- function(...) fn_moved("node_is_min", "node_is_min", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_neighbor <- function(...) fn_moved("node_is_neighbor", "node_is_neighbor", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_pendant <- function(...) fn_moved("node_is_pendant", "node_is_pendant", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_random <- function(...) fn_moved("node_is_random", "node_is_random", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_recovered <- function(...) fn_moved("node_is_recovered", "node_is_recovered", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_is_universal <- function(...) fn_moved("node_is_universal", "node_is_universal", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_bridge <- function(...) fn_moved("tie_is_bridge", "tie_is_bridge", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_cyclical <- function(...) fn_moved("tie_is_cyclical", "tie_is_cyclical", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_feedback <- function(...) fn_moved("tie_is_feedback", "tie_is_feedback", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_imbalanced <- function(...) fn_moved("tie_is_imbalanced", "tie_is_imbalanced", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_loop <- function(...) fn_moved("tie_is_loop", "tie_is_loop", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_max <- function(...) fn_moved("tie_is_max", "tie_is_max", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_min <- function(...) fn_moved("tie_is_min", "tie_is_min", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_multiple <- function(...) fn_moved("tie_is_multiple", "tie_is_multiple", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_path <- function(...) fn_moved("tie_is_path", "tie_is_path", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_random <- function(...) fn_moved("tie_is_random", "tie_is_random", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_reciprocated <- function(...) fn_moved("tie_is_reciprocated", "tie_is_reciprocated", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_simmelian <- function(...) fn_moved("tie_is_simmelian", "tie_is_simmelian", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_transitive <- function(...) fn_moved("tie_is_transitive", "tie_is_transitive", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_triangular <- function(...) fn_moved("tie_is_triangular", "tie_is_triangular", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -tie_is_triplet <- function(...) fn_moved("tie_is_triplet", "tie_is_triplet", version = "2.0.0") - #' @describeIn defunct Deprecated on 2026-03-22. #' @export net_adhesion <- function(...) fn_moved("net_adhesion", "net_by_adhesion", version = "2.0.0") @@ -820,98 +692,6 @@ tie_degree <- function(...) fn_moved("tie_degree", "tie_by_degree", version = "2 #' @export tie_eigenvector <- function(...) fn_moved("tie_eigenvector", "tie_by_eigenvector", version = "2.0.0") -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_adopter <- function(...) fn_moved("node_in_adopter", "node_in_adopter", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_automorphic <- function(...) fn_moved("node_in_automorphic", "node_in_automorphic", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_betweenness <- function(...) fn_moved("node_in_betweenness", "node_in_betweenness", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_brokering <- function(...) fn_moved("node_in_brokering", "node_in_brokering", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_community <- function(...) fn_moved("node_in_community", "node_in_community", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_component <- function(...) fn_moved("node_in_component", "node_in_component", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_core <- function(...) fn_moved("node_in_core", "node_in_core", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_eigen <- function(...) fn_moved("node_in_eigen", "node_in_eigen", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_equivalence <- function(...) fn_moved("node_in_equivalence", "node_in_equivalence", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_fluid <- function(...) fn_moved("node_in_fluid", "node_in_fluid", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_greedy <- function(...) fn_moved("node_in_greedy", "node_in_greedy", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_infomap <- function(...) fn_moved("node_in_infomap", "node_in_infomap", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_leiden <- function(...) fn_moved("node_in_leiden", "node_in_leiden", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_louvain <- function(...) fn_moved("node_in_louvain", "node_in_louvain", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_optimal <- function(...) fn_moved("node_in_optimal", "node_in_optimal", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_partition <- function(...) fn_moved("node_in_partition", "node_in_partition", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_regular <- function(...) fn_moved("node_in_regular", "node_in_regular", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_roulette <- function(...) fn_moved("node_in_roulette", "node_in_roulette", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_spinglass <- function(...) fn_moved("node_in_spinglass", "node_in_spinglass", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_strong <- function(...) fn_moved("node_in_strong", "node_in_strong", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_structural <- function(...) fn_moved("node_in_structural", "node_in_structural", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_walktrap <- function(...) fn_moved("node_in_walktrap", "node_in_walktrap", version = "2.0.0") - -#' @describeIn defunct Deprecated on 2026-03-22. -#' @export -node_in_weak <- function(...) fn_moved("node_in_weak", "node_in_weak", version = "2.0.0") - #' @describeIn defunct Deprecated on 2026-03-22. #' @export net_by_brokerage <- function(...) fn_moved("net_by_brokerage", "net_x_brokerage", version = "2.0.0") diff --git a/R/modif_correlation.R b/R/modif_correlation.R index e8231518..68ee30b7 100644 --- a/R/modif_correlation.R +++ b/R/modif_correlation.R @@ -31,6 +31,21 @@ to_correlation.default <- function(.data, method = NULL){ as_input(.data, to_correlation, method = method) } +#' @export +to_correlation.matrix <- function(.data, method = NULL){ + if(is.null(method)) method <- ifelse(is_twomode(.data), + "all", + ifelse(is_complex(.data), + "complex", + ifelse(is_directed(.data), + "recip", "diag"))) + switch(method, + all = .corTwomode(.data), + complex = .corComplex(.data), + recip = .corRecip(.data), + diag = .corDiag(.data)) +} + #' @export to_correlation.tbl_graph <- function(.data, method = NULL){ if(missing(.data)) {expect_nodes(); .data <- .G()} # nocov diff --git a/R/reexports_classes.R b/R/reexports_classes.R index bda77605..e751d371 100644 --- a/R/reexports_classes.R +++ b/R/reexports_classes.R @@ -28,23 +28,139 @@ NULL #' @rdname expect #' @export expect_nodes <- function(.data) { - if(missing(.data)){ - if (!tidygraph::.graph_context$free() && tidygraph::.graph_context$active() != "nodes") { - snet_abort("This call requires nodes to be active", call. = FALSE) - } - tidygraph::.G() - } else .data + + obj <- expect_igraph(.data, "nodes") + + if (is.null(obj)) + snet_abort( + "This call requires nodes to be active", + call. = FALSE + ) + + obj } #' @rdname expect #' @export expect_ties <- function(.data) { - if(missing(.data)){ - if (!tidygraph::.graph_context$free() && tidygraph::.graph_context$active() != "edges") { - snet_abort("This call requires ties to be active", call. = FALSE) + + obj <- expect_igraph(.data, "edges") + + if (is.null(obj)) + snet_abort( + "This call requires ties to be active", + call. = FALSE + ) + + obj +} + +expect_igraph <- function(.data, context = NULL) { + + if (!missing(.data)) + return(as_igraph(.data)) + + if (!is.null(context)) { + + obj <- active_network(context) + + if (!is.null(obj)) + return(as_igraph(obj)) + } + + tg <- tryCatch( + tidygraph::.G(), + error = function(e) NULL + ) + + if (!is.null(tg)) + return(as_igraph(tg)) + + NULL +} + +.active_context <- new.env(parent = emptyenv()) +.active_context$data <- NULL +.active_context$active <- NULL + +get_active_context <- function() { + list( + data = .active_context$data, + active = .active_context$active + ) +} + +set_active_context <- function(data, active) { + .active_context$data <- data + .active_context$active <- active +} + +clear_active_context <- function() { + .active_context$data <- NULL + .active_context$active <- NULL +} + +active_network <- function(required = NULL) { + + ctx <- get_active_context() + + if (!is.null(ctx$data)) { + + if (!is.null(required) && + !identical(ctx$active, required)) { + snet_abort( + paste0( + "This call requires ", + if (identical(required, "edges")) "ties" else required, + " to be active" + ), + call. = FALSE + ) } - tidygraph::.G() - } else .data + + return(ctx$data) + } + + tg <- tryCatch({ + + if (!tidygraph::.graph_context$free()) { + + active <- tidygraph::.graph_context$active() + + if (!is.null(required) && + active != required) { + snet_abort( + paste0( + "This call requires ", + if (identical(required, "edges")) "ties" else required, + " to be active" + ), + call. = FALSE + ) + } + + tidygraph::.G() + } else { + NULL + } + + }, error = function(e) NULL) + + tg +} + +with_active_context <- function(data, active, expr) { + + old <- get_active_context() + + on.exit( + set_active_context(old$data, old$active), + add = TRUE + ) + + set_active_context(data, active) + + eval.parent(substitute(expr)) } # nocov end \ No newline at end of file diff --git a/R/zzz.R b/R/zzz.R index 633c403a..27d47637 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -21,17 +21,19 @@ greet_startup_cli <- function() { tips <- c( - "i" = "There are lots of ways to contribute to {.pkg manynet} at {.url https://github.com/stocnet/manynet/}.", - "i" = "Please share bugs, issues, or feature requests at {.url https://github.com/stocnet/manynet/issues}. It's really helpful!", + "i" = "Contribute to {.pkg manynet} at {.url https://github.com/stocnet/manynet/}.", + "i" = "Don't hesitate to share bugs, issues, or feature requests at {.url https://github.com/stocnet/manynet/issues}.", # "i" = "To suppress package startup messages, use: `suppressPackageStartupMessages(library({.pkg manynet}))`.", # "i" = "Changing the theme of all your graphs is straightforward with `set_manynet_theme()`", "i" = "If too many messages appear in the console, run `options(snet_verbosity = 'quiet')`", "i" = "Explore changes since the last version with {.code news(package = 'manynet')}.", + "i" = "Visualisation functions have been moved to {.pkg autograph}. Install everything with `install.packages('migraph')`.", + "i" = "Analytic functions have been moved to {.pkg netrics}. Install everything with `install.packages('migraph')`.", "i" = "Visit {.url https://stocnet.github.io/manynet/} to learn more.", - "i" = "The 'Function Overview' may suggest options: {.url https://stocnet.github.io/manynet/reference/index.html}.", + "i" = "Discover new functions at: {.url https://stocnet.github.io/manynet/reference/index.html}.", "i" = "Discover {.emph stocnet} R packages at {.url https://github.com/stocnet/}.", # "i" = "Star me at {.url https://github.com/users/follow?target=jhollway}.", - "i" = "You can list all the tutorials available in {.pkg manynet} using {.fn run_tute}, and run them too!" + "i" = "List the tutorials available in {.pkg manynet} using {.fn run_tute}, and run them too!" ) snet_info(sample(tips, 1)) } diff --git a/README.Rmd b/README.Rmd index ed133643..ef089c52 100644 --- a/README.Rmd +++ b/README.Rmd @@ -54,17 +54,24 @@ as well as one-mode and two-mode, directed and undirected, weighted, unweighted, longitudinal and dynamic networks. If you have social network data, `{manynet}` probably has the tools to help you work with it. +NB: If you are looking for the visualisation functions that used to be +in `{manynet}`, these have been migrated to their own package `{autograph}`. +If you are looking for the network analytic functions that used to be in +`{manynet}`, these have been migrated to their own package `{netrics}`. +If you install and load `{migraph}`, +all these packages will be installed and loaded and you can use all functionality, past and present. + - [Making](#making) - [Importing network data](#importing-network-data) - [Identifying network data](#identifying-network-data) - [Inventing network data](#inventing-network-data) - [Manipulating](#manipulating) - [Translating network data](#translating-network-data) + - [Wrangling with dplyr-style verbs](#wrangling-with-dplyr-style-verbs) - [Modifying](#modifying) - [Reformatting](#reformatting) - [Transforming](#transforming) - [Splitting and Joining](#splitting-and-joining) - - [Extracting](#extracting) - [Installation](#installation) - [Stable](#stable) - [Development](#development) diff --git a/README.md b/README.md index 0c628843..47b5c82e 100644 --- a/README.md +++ b/README.md @@ -43,17 +43,26 @@ unweighted, and signed, longitudinal and dynamic networks. If you have social network data, `{manynet}` probably has the tools to help you work with it. +NB: If you are looking for the visualisation functions that used to be +in `{manynet}`, these have been migrated to their own package +`{autograph}`. If you are looking for the network analytic functions +that used to be in `{manynet}`, these have been migrated to their own +package `{netrics}`. If you install and load `{migraph}`, all these +packages will be installed and loaded and you can use all functionality, +past and present. + - [Making](#making) - [Importing network data](#importing-network-data) - [Identifying network data](#identifying-network-data) - [Inventing network data](#inventing-network-data) - [Manipulating](#manipulating) - [Translating network data](#translating-network-data) + - [Wrangling with dplyr-style + verbs](#wrangling-with-dplyr-style-verbs) - [Modifying](#modifying) - [Reformatting](#reformatting) - [Transforming](#transforming) - [Splitting and Joining](#splitting-and-joining) - - [Extracting](#extracting) - [Installation](#installation) - [Stable](#stable) - [Development](#development) diff --git a/cran-comments.md b/cran-comments.md index 0f731db3..062b4869 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,6 +1,6 @@ ## Test environments -* local R installation, aarch64-apple-darwin20, R 4.5.2 +* local R installation, aarch64-apple-darwin23, R 4.6.0 * macOS 15.7.7 (on Github), R 4.6.0 * Microsoft Windows Server 2025 10.0.26100 (on Github), R 4.6.0 * Ubuntu 24.04.4 (on Github), R 4.6.0 @@ -9,4 +9,5 @@ 0 errors | 0 warnings | 0 notes -- Fixed README link issue \ No newline at end of file +- Fixed README link issue +- Together with parallel submissions of 'netrics' and 'migraph', should pass all reverse dependency checks now too \ No newline at end of file diff --git a/man/defunct.Rd b/man/defunct.Rd index 66fcfad0..bdc16fce 100644 --- a/man/defunct.Rd +++ b/man/defunct.Rd @@ -52,38 +52,6 @@ \alias{node_triad_census} \alias{node_walktrap} \alias{node_weak_components} -\alias{node_is_core} -\alias{node_is_cutpoint} -\alias{node_is_exposed} -\alias{node_is_fold} -\alias{node_is_independent} -\alias{node_is_infected} -\alias{node_is_isolate} -\alias{node_is_latent} -\alias{node_is_max} -\alias{node_is_mean} -\alias{node_is_mentor} -\alias{node_is_min} -\alias{node_is_neighbor} -\alias{node_is_pendant} -\alias{node_is_random} -\alias{node_is_recovered} -\alias{node_is_universal} -\alias{tie_is_bridge} -\alias{tie_is_cyclical} -\alias{tie_is_feedback} -\alias{tie_is_imbalanced} -\alias{tie_is_loop} -\alias{tie_is_max} -\alias{tie_is_min} -\alias{tie_is_multiple} -\alias{tie_is_path} -\alias{tie_is_random} -\alias{tie_is_reciprocated} -\alias{tie_is_simmelian} -\alias{tie_is_transitive} -\alias{tie_is_triangular} -\alias{tie_is_triplet} \alias{net_adhesion} \alias{net_assortativity} \alias{net_balance} @@ -181,29 +149,6 @@ \alias{tie_cohesion} \alias{tie_degree} \alias{tie_eigenvector} -\alias{node_in_adopter} -\alias{node_in_automorphic} -\alias{node_in_betweenness} -\alias{node_in_brokering} -\alias{node_in_community} -\alias{node_in_component} -\alias{node_in_core} -\alias{node_in_eigen} -\alias{node_in_equivalence} -\alias{node_in_fluid} -\alias{node_in_greedy} -\alias{node_in_infomap} -\alias{node_in_leiden} -\alias{node_in_louvain} -\alias{node_in_optimal} -\alias{node_in_partition} -\alias{node_in_regular} -\alias{node_in_roulette} -\alias{node_in_spinglass} -\alias{node_in_strong} -\alias{node_in_structural} -\alias{node_in_walktrap} -\alias{node_in_weak} \alias{net_by_brokerage} \alias{net_by_dyad} \alias{net_by_hazard} @@ -322,70 +267,6 @@ node_walktrap(...) node_weak_components(...) -node_is_core(...) - -node_is_cutpoint(...) - -node_is_exposed(...) - -node_is_fold(...) - -node_is_independent(...) - -node_is_infected(...) - -node_is_isolate(...) - -node_is_latent(...) - -node_is_max(...) - -node_is_mean(...) - -node_is_mentor(...) - -node_is_min(...) - -node_is_neighbor(...) - -node_is_pendant(...) - -node_is_random(...) - -node_is_recovered(...) - -node_is_universal(...) - -tie_is_bridge(...) - -tie_is_cyclical(...) - -tie_is_feedback(...) - -tie_is_imbalanced(...) - -tie_is_loop(...) - -tie_is_max(...) - -tie_is_min(...) - -tie_is_multiple(...) - -tie_is_path(...) - -tie_is_random(...) - -tie_is_reciprocated(...) - -tie_is_simmelian(...) - -tie_is_transitive(...) - -tie_is_triangular(...) - -tie_is_triplet(...) - net_adhesion(...) net_assortativity(...) @@ -580,52 +461,6 @@ tie_degree(...) tie_eigenvector(...) -node_in_adopter(...) - -node_in_automorphic(...) - -node_in_betweenness(...) - -node_in_brokering(...) - -node_in_community(...) - -node_in_component(...) - -node_in_core(...) - -node_in_eigen(...) - -node_in_equivalence(...) - -node_in_fluid(...) - -node_in_greedy(...) - -node_in_infomap(...) - -node_in_leiden(...) - -node_in_louvain(...) - -node_in_optimal(...) - -node_in_partition(...) - -node_in_regular(...) - -node_in_roulette(...) - -node_in_spinglass(...) - -node_in_strong(...) - -node_in_structural(...) - -node_in_walktrap(...) - -node_in_weak(...) - net_by_brokerage(...) net_by_dyad(...) @@ -769,70 +604,6 @@ wherever possible and update your scripts accordingly. \item \code{node_weak_components()}: Deprecated on 2026-03-22. -\item \code{node_is_core()}: Deprecated on 2026-03-22. - -\item \code{node_is_cutpoint()}: Deprecated on 2026-03-22. - -\item \code{node_is_exposed()}: Deprecated on 2026-03-22. - -\item \code{node_is_fold()}: Deprecated on 2026-03-22. - -\item \code{node_is_independent()}: Deprecated on 2026-03-22. - -\item \code{node_is_infected()}: Deprecated on 2026-03-22. - -\item \code{node_is_isolate()}: Deprecated on 2026-03-22. - -\item \code{node_is_latent()}: Deprecated on 2026-03-22. - -\item \code{node_is_max()}: Deprecated on 2026-03-22. - -\item \code{node_is_mean()}: Deprecated on 2026-03-22. - -\item \code{node_is_mentor()}: Deprecated on 2026-03-22. - -\item \code{node_is_min()}: Deprecated on 2026-03-22. - -\item \code{node_is_neighbor()}: Deprecated on 2026-03-22. - -\item \code{node_is_pendant()}: Deprecated on 2026-03-22. - -\item \code{node_is_random()}: Deprecated on 2026-03-22. - -\item \code{node_is_recovered()}: Deprecated on 2026-03-22. - -\item \code{node_is_universal()}: Deprecated on 2026-03-22. - -\item \code{tie_is_bridge()}: Deprecated on 2026-03-22. - -\item \code{tie_is_cyclical()}: Deprecated on 2026-03-22. - -\item \code{tie_is_feedback()}: Deprecated on 2026-03-22. - -\item \code{tie_is_imbalanced()}: Deprecated on 2026-03-22. - -\item \code{tie_is_loop()}: Deprecated on 2026-03-22. - -\item \code{tie_is_max()}: Deprecated on 2026-03-22. - -\item \code{tie_is_min()}: Deprecated on 2026-03-22. - -\item \code{tie_is_multiple()}: Deprecated on 2026-03-22. - -\item \code{tie_is_path()}: Deprecated on 2026-03-22. - -\item \code{tie_is_random()}: Deprecated on 2026-03-22. - -\item \code{tie_is_reciprocated()}: Deprecated on 2026-03-22. - -\item \code{tie_is_simmelian()}: Deprecated on 2026-03-22. - -\item \code{tie_is_transitive()}: Deprecated on 2026-03-22. - -\item \code{tie_is_triangular()}: Deprecated on 2026-03-22. - -\item \code{tie_is_triplet()}: Deprecated on 2026-03-22. - \item \code{net_adhesion()}: Deprecated on 2026-03-22. \item \code{net_assortativity()}: Deprecated on 2026-03-22. @@ -1027,52 +798,6 @@ wherever possible and update your scripts accordingly. \item \code{tie_eigenvector()}: Deprecated on 2026-03-22. -\item \code{node_in_adopter()}: Deprecated on 2026-03-22. - -\item \code{node_in_automorphic()}: Deprecated on 2026-03-22. - -\item \code{node_in_betweenness()}: Deprecated on 2026-03-22. - -\item \code{node_in_brokering()}: Deprecated on 2026-03-22. - -\item \code{node_in_community()}: Deprecated on 2026-03-22. - -\item \code{node_in_component()}: Deprecated on 2026-03-22. - -\item \code{node_in_core()}: Deprecated on 2026-03-22. - -\item \code{node_in_eigen()}: Deprecated on 2026-03-22. - -\item \code{node_in_equivalence()}: Deprecated on 2026-03-22. - -\item \code{node_in_fluid()}: Deprecated on 2026-03-22. - -\item \code{node_in_greedy()}: Deprecated on 2026-03-22. - -\item \code{node_in_infomap()}: Deprecated on 2026-03-22. - -\item \code{node_in_leiden()}: Deprecated on 2026-03-22. - -\item \code{node_in_louvain()}: Deprecated on 2026-03-22. - -\item \code{node_in_optimal()}: Deprecated on 2026-03-22. - -\item \code{node_in_partition()}: Deprecated on 2026-03-22. - -\item \code{node_in_regular()}: Deprecated on 2026-03-22. - -\item \code{node_in_roulette()}: Deprecated on 2026-03-22. - -\item \code{node_in_spinglass()}: Deprecated on 2026-03-22. - -\item \code{node_in_strong()}: Deprecated on 2026-03-22. - -\item \code{node_in_structural()}: Deprecated on 2026-03-22. - -\item \code{node_in_walktrap()}: Deprecated on 2026-03-22. - -\item \code{node_in_weak()}: Deprecated on 2026-03-22. - \item \code{net_by_brokerage()}: Deprecated on 2026-03-22. \item \code{net_by_dyad()}: Deprecated on 2026-03-22. diff --git a/man/make_stochastic.Rd b/man/make_stochastic.Rd index 89c7e01c..e7725f97 100644 --- a/man/make_stochastic.Rd +++ b/man/make_stochastic.Rd @@ -126,14 +126,15 @@ Watts, Duncan J., and Steven H. Strogatz. 1998. Barabasi, Albert-Laszlo, and Reka Albert. 1999. “Emergence of Scaling in Random Networks.” \emph{Science} 286(5439):509–12. -\doi{10.1126/science.286.5439.509}. +\doi{10.1126/science.286.5439.509} } \subsection{On the forest-fire model}{ Leskovec, Jure, Jon Kleinberg, and Christos Faloutsos. 2007. -"\href{https://www.cs.cmu.edu/~jure/pubs/powergrowth-tkdd.pdf}{Graph evolution: Densification and shrinking diameters}". +"Graph evolution: Densification and shrinking diameters". \emph{ACM transactions on Knowledge Discovery from Data}, 1(1): 2-es. +\doi{10.1145/1217299.1217301} } } \seealso{ diff --git a/man/manip_changes.Rd b/man/manip_changes.Rd index 7bcdb13a..1aadb0fc 100644 --- a/man/manip_changes.Rd +++ b/man/manip_changes.Rd @@ -86,7 +86,7 @@ Below are the currently implemented S3 methods for these functions: \if{html}{\out{