From 25cb322d244542d76613bb5918d06cc86b24bf20 Mon Sep 17 00:00:00 2001 From: Chris Sobczak Date: Mon, 15 Jun 2026 20:04:48 -0700 Subject: Adjust --- R/networkplot.R | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'R') diff --git a/R/networkplot.R b/R/networkplot.R index 10dfc01..b95d979 100644 --- a/R/networkplot.R +++ b/R/networkplot.R @@ -10,15 +10,27 @@ #' @param title Optional plot title #' @param groups Optional data.frame mapping nodes to groups #' @param group_label Optional string labeling the kind of grouping -#' @param r_label The string naming the relationship type (default 'Correlation') #' #' @return A ggraph object #' #' @import ggraph #' @import igraph #' +#' @example +#' set.seed(1) +#' X <- matrix(rnorm(100), ncol = 10) +#' colnames(X) <- letters[1:10] +#' R <- cor(X) +#' networkplot(R, title = 'Networkplot without groups') +#' +#' groups <- data.frame( +#' node = letters[1:5], +#' group = c(rep('A', 5), rep('B', 5)) +#' ) +#' networkplot(R, groups = groups, group_label = 'Letter', title = 'Networkplot with groups') +#' #' @export -networkplot <- function(R, groups = NULL, group_label = NULL, title = NULL, r_label = 'Correlation'){ +networkplot <- function(R, groups = NULL, group_label = NULL, title = NULL){ Rm <- tryCatch({ if(is.matrix(R)){ if(nrow(R) != ncol(R)) stop('R must be square') @@ -140,8 +152,7 @@ networkplot <- function(R, groups = NULL, group_label = NULL, title = NULL, r_la mid = 'white', high = 'blue', midpoint = 0, - limits = c(-1, 1), - name = r_label + limits = c(-1, 1) ) + # operates on node data from the layout # leaf is a logical vector (provided by the ggraph object g) @@ -177,6 +188,7 @@ networkplot <- function(R, groups = NULL, group_label = NULL, title = NULL, r_la y = c(-1.2, 1.2) ) + ggraph::scale_edge_alpha(guide = 'none') + + ggplot2::guides(edge_colour = 'none') + ggplot2::theme_void() if(!is.null(title)){ -- cgit v1.2.3