make_graph_from_veda_df: Create a igraph from a veda dataframe

View source: R/network_analysis.R

make_graph_from_veda_dfR Documentation

Create a igraph from a veda dataframe

Description

Use the full dataset from prep_data to create an igraph graph. Processes are nodes and commodity flows are represented by edges. When the data is for a single year, the edge weights are the values are determined by the var_fin and var_fout variables of the given process/commodity. Note that since TIMES does not give information of how a given var_fout is split over downstream commodities, an assumption has to be made. Here, the weight is assigned in proportion to the ratio of var_fin variables of downstream commodities linked to the originating process.

Usage

make_graph_from_veda_df(
  dat,
  node_labels = process_description,
  edge_labels = commodity_description,
  input_data_type = "vd"
)

Arguments

dat

Tibble output from prep_data() %>% define_sector_from_*().

node_labels

Column in dat for labelling nodes.

edge_labels

Column in dat for labelling edges.

input_data_type

Character. "vd" or "vdt"

Value

igraph graph object. Edge attributes: commodity, commodity description

Examples

 data(demos_001_sector)
 g <- demos_001_sector %>%
    make_graph_from_veda_df(node_labels = process_description,
                            edge_labels = commodity_description
             )
 E(g)
 E(g)$weight
 E(g)$commodity

 # If a singe period selected, the weight is set to the var_fout pv
 g_w <- demos_001_sector %>%
   filter(period == 2005) %>%
    make_graph_from_veda_df(node_labels = process_description,
                            edge_labels = commodity_description
             )

 E(g_w)
 E(g_w)$weight
 E(g_w)$commodity


DataScienceScotland/vedar documentation built on April 3, 2022, 10:32 p.m.