LoslegenKostenlos loslegen

Labeling nodes

In this exercise, you will label the nodes in the network. You are given a dataframe called customers with the same customer IDs as in the network. Each customer has an indication of whether they churned or not, given by 1 or 0 respectively. You will add the churn status to the nodes of the network and visualize it.

Note that a network can have both node and edge attributes. The node attributes are represented by the function V() (for vertex) and the edge attributes by the function E().
The node attributes of the churn network are V(network).

Diese Übung ist Teil des Kurses

Predictive Analytics using Networked Data in R

Kurs anzeigen

Anleitung zur Übung

  • Inspect the customers dataframe with the head() function.
  • Use the table() function to count the number of churners and non-churners in the customers dataframe.
  • Use the V() function to add a node attribute called churn to the network and assign the churn column of the customers dataframe to it.
  • Visualize the network by calling the plot() function.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Inspect the customers dataframe
___(customers)

# Count the number of churners and non-churners
table(customers$___)

# Add a node attribute called churn
___(network)$___ <- customers$churn

# Visualize the network
___(___, vertex.label = NA, edge.label = NA,
    edge.color = 'black', vertex.size = 2)
Code bearbeiten und ausführen