Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

get_agg_degree_in

Get an aggregate value from the indegree of nodes


Description

Get a single, aggregate value from the indegree values for all nodes in a graph, or, a subset of graph nodes.

Usage

get_agg_degree_in(graph, agg, conditions = NULL)

Arguments

graph

A graph object of class dgr_graph.

agg

The aggregation function to use for summarizing indegree values from graph nodes. The following aggregation functions can be used: sum, min, max, mean, or median.

conditions

An option to use filtering conditions for the nodes to consider.

Value

A vector with an aggregate indegree value.

Examples

# Create a random graph using the
# `add_gnm_graph()` function
graph <-
  create_graph() %>%
  add_gnm_graph(
    n = 20,
    m = 35,
    set_seed = 23) %>%
  set_node_attrs(
    node_attr = value,
    values = rnorm(
      n = count_nodes(.),
      mean = 5,
      sd = 1) %>% round(1))

# Get the mean indegree value
# from all nodes in the graph
graph %>%
  get_agg_degree_in(
    agg = "mean")

# Other aggregation functions
# can be used (`min`, `max`,
# `median`, `sum`); let's get
# the median in this example
graph %>%
  get_agg_degree_in(
    agg = "median")

# The aggregation of indegree
# can occur for a subset of the
# graph nodes and this is made
# possible by specifying
# `conditions` for the nodes
graph %>%
  get_agg_degree_in(
    agg = "mean",
    conditions = value > 5.0)

DiagrammeR

Graph/Network Visualization

v1.0.6.1
MIT + file LICENSE
Authors
Richard Iannone [aut, cre] (<https://orcid.org/0000-0003-3925-190X>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.