LoslegenKostenlos loslegen

Counting nodes and computing connectance

In this exercise, you will count the number of each type of node using the customers dataframe. The churn column has two different values:

  • 0 for non-churners
  • 1 for churners

You will also compute the network's connectance using the formula \(p=\frac{2E}{N(N-1)}\) where \(N\) is the number of nodes and \(E\) the number of edges in the network.

Diese Übung ist Teil des Kurses

Predictive Analytics using Networked Data in R

Kurs anzeigen

Anleitung zur Übung

  • Count the number of churn nodes by conditioning on customers$churn.
  • Count the number of non-churn nodes by conditioning on customers$churn.
  • Count the total number of nodes and name the variable nodes.
  • Compute the network's connectance using the formula for \(p\) shown above. You can use edges from the previous exercise.

Interaktive Übung

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

# Count the number of churn nodes
ChurnNodes <- sum(customers$___ == ___)
 
# Count the number of non-churn nodes
NonChurnNodes <- sum(___)
 
# Count the total number of nodes
___ <- ChurnNodes + NonChurnNodes
 
# Compute the network connectance
connectance <- 2 * ___ / ___ / (nodes - 1)

# Print the value
connectance
Code bearbeiten und ausführen