# NOT RUN {
library(sp)
data(meuse)
coordinates(meuse) <- ~x+y
# Display rows with NA
meuse@data[!complete.cases(meuse@data),]
# Remove all NA's in rows (and associated points)
meuse2 <- sp.na.omit(meuse)
dim(meuse)
dim(meuse2)
# Plot deleted points in red
plot(meuse, col='red', pch=20)
plot(meuse2, col='black', pch=20, add=TRUE)
# Remove NA's associated with specific column
meuse2 <- sp.na.omit(meuse, col.name = "om")
head(meuse@data)
head(meuse2@data)
# }
Run the code above in your browser using DataLab