Skip to contents

Returns the mean of a neighborhood's attribute for all or a subset of nodes in the language network.

Usage

get_neighbor_mean(network, node_name = NULL, attribute)

Arguments

network

An igraph network object, generated by make_network() or make_network_sep() functions.

node_name

A vector containing node names to obtain values for. Node names must be found in igraph::V(network)$name. If unspecified, the default is to return values for all nodes in the network.

attribute

A string stating the node attribute to obtain the mean values for. The attribute must be found in igraph::vertex_attr_names(network). Typically it will be one of the node attribute columns in the item_df data frame object used to create the network.

Value

A named numeric vector.

Examples

# Use the demo data for executing examples

  test <- make_network(sample1)
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |========                                                              |  11%
  |                                                                            
  |================                                                      |  22%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |==============================================================        |  89%
  get_neighbor_mean(network = test, attribute = "length") # all nodes
#>     cat     bat     cut     cap     hat    chat    heat    hate spinach 
#>     3.2     3.0     3.0     3.0     3.6     3.0     3.0     3.0     NaN 
  get_neighbor_mean(network = test, node_name = "cat", attribute = "length") # for 1 node
#> cat 
#> 3.2