Let's say I have two vectors
x <- c(1, 2, 3, NA, 5, 6, NA, NA, 10, 11, 12, NA, NA, 13)
y <- c(14, 15, 16, 17, 18 ,19, 20, 21, 22, 23, 24, 25, 26 ,27)
They have both length of 14. I want remove NAs from x and the value that corresponds to it in y. And obtain x and y as equal lengths.
for (i in 1:length(x)) {
for (j in 1:length(y)) {
if(is.na(x[, i]==y[, j))
x <- x[-which(x %n% y)]
}
}
But it doesn't give what I want. Can you please help me ?