## Create a Matrix with NAs:
X = matrix(rnorm(100), ncol = 5)
# a single NA inside:
X[3, 5] = NA
# three in a row inside:
X[17, 2:4] = c(NA, NA, NA)
# three in a column inside:
X[13:15, 4] = c(NA, NA, NA)
# two at the right border:
X[11:12, 5] = c(NA, NA)
# one in the lower left corner:
X[20, 1] = NA
print(X)
## removeNA -
# Remove rows with NA's
removeNA(X)
# Now we have only 12 lines!
## substiuteNA -
# Subsitute NA's by zeros or column mean
substituteNA(X, type = "zeros")
substituteNA(X, type = "mean")
## interpNA -
# Interpolate NA's liearily:
interpNA(X, method = "linear")
# Note the corner missing value cannot be interpolated!
# Take previous values in a column:
interpNA(X, method = "before")
# Also here, the corner value is excluded
Run the code above in your browser using DataLab