BaşlayınÜcretsiz Başlayın

Edge attributes and subsetting

In this exercise you will learn how to add attributes to edges in the network and view them. For instance, we will add the attribute 'hours' that represents how many hours per week each pair of friends spend with each other.

Bu egzersiz

Network Analysis in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Create a new edge attribute called 'hours' from the vector hours using set_edge_attr().
  • View all edge attributes using edge_attr().
  • View all edges that include the person "Britt".
  • View all edges where the attribute hours is greater than or equal to 4 hours.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

library(igraph)

# View hours
hours

# Create new edge attribute called 'hours'
g <- set_edge_attr(g, ___, value = ___)

# View edge attributes of graph object
___(g)

# Find all edges that include "Britt"
E(g)[[.inc('___')]]  

# Find all pairs that spend 4 or more hours together per week
E(g)[[hours>=___]]  
Kodu Düzenle ve Çalıştır