diff options
| -rw-r--r-- | R/networkplot.R | 20 | ||||
| -rw-r--r-- | README.Rmd | 2 | ||||
| -rw-r--r-- | man/networkplot.Rd | 10 |
3 files changed, 18 insertions, 14 deletions
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)){ @@ -27,7 +27,7 @@ You can install the development version of rcsobczak like so: ``` r # FILL THIS IN! HOW CAN PEOPLE INSTALL YOUR DEV PACKAGE? install.packages('pak') -pak::pkg_install('git::https://codeberg.org/csobczak/rcsobczak') +pak::pkg_install('git::https://codeberg.org/csobczak/csobczak.r') ``` ## Example diff --git a/man/networkplot.Rd b/man/networkplot.Rd index 12e5363..7d881ab 100644 --- a/man/networkplot.Rd +++ b/man/networkplot.Rd @@ -4,13 +4,7 @@ \alias{networkplot} \title{Network Plot} \usage{ -networkplot( - R, - groups = NULL, - group_label = NULL, - title = NULL, - r_label = "Correlation" -) +networkplot(R, groups = NULL, group_label = NULL, title = NULL) } \arguments{ \item{R}{A square numeric matrix with names columns and rows} @@ -20,8 +14,6 @@ networkplot( \item{group_label}{Optional string labeling the kind of grouping} \item{title}{Optional plot title} - -\item{r_label}{The string naming the relationship type (default 'Correlation')} } \value{ A ggraph object |
