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.
本练习是课程的一部分
Predictive Analytics using Networked Data in R
练习说明
- Use
summary()to inspect theRelationalNeighborSecondfeature. - Find the indices of the observations that are missing using
which()and assign to the variabletoReplace. - Use the
toReplacevector to replace the missing values instudentnetworkdata$RelationalNeighborSecondwith a zero. - Inspect
RelationalNeighborSecondagain to make sure there are no longer any missing value.
交互式实操练习
通过完成这段示例代码来试试这个练习。
# 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
___(___$___)