MulaiMulai sekarang secara gratis

Counting types of edges

In this exercise, you will count the number of each edge type using the edgeType column in the edgeList dataframe. In the edgeList$edgeType column, there are three different values:

  • 0 for edges that connect two non-churn nodes.
  • 1 for edges that connect a non-churn and a churn node. These are called mixed or cross-label edges.
  • 2 for edges that connect two churn nodes.

Latihan ini adalah bagian dari kursus

Predictive Analytics using Networked Data in R

Lihat Kursus

Petunjuk latihan

  • Count the number of churn edges by conditioning on edgeList$edgeType. Assign the value to ChurnEdges.
  • Count the number of non-churn edges by conditioning on edgeList$edgeType. Assign the value to NonChurnEdges.
  • Count the number of mixed edges by conditioning on edgeList$edgeType. Assign the value to MixedEdges.
  • Count the total number of edges and assign the value to edges.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Count churn edges
ChurnEdges <- sum(edgeList$edgeType == ___)
 
# Count non-churn edges
NonChurnEdges <- sum(___ == ___)
 
# Count mixed edges
MixedEdges <- ___
 
# Count all edges
___ <- ChurnEdges + NonChurnEdges + MixedEdges

#Print the number of edges
edges
Edit dan Jalankan Kode