Aan de slagGa gratis aan de slag

Replace missing values

In the last exercise, you noticed that for six observations, the value of RelationalNeighborSecond was missing. In this exercise, you will replace those missing values with 0.

Deze oefening maakt deel uit van de cursus

Predictive Analytics using Networked Data in R

Cursus bekijken

Oefeninstructies

  • Use summary() to inspect the RelationalNeighborSecond feature.
  • Find the indices of the observations that are missing using which() and assign to the variable toReplace.
  • Use the toReplace vector to replace the missing values instudentnetworkdata$RelationalNeighborSecond with a zero.
  • Inspect RelationalNeighborSecond again to make sure there are no longer any missing value.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Inspect the feature
___(studentnetworkdata$RelationalNeighborSecond)

# Find the indices of the missing values
toReplace <- ___(is.na(studentnetworkdata$___))

# Replace the missing values with 0
studentnetworkdata$RelationalNeighborSecond[___] <- ___

# Inspect the feature again
___(___$___)
Code bewerken en uitvoeren