I am removing values from the vector using the minus sign in front of the index. Like this:
scores <- scores[-indexes.to.delete]
Sometimes the indexes.to.deletevector is empty, i.e. N / A. Thus, the vector scoresmust remain unchanged. However, I get an empty scoresvector when indexes.to.deleteempty.
Example:
x <- c(1, 2, 3);
y <- c(4, 5, 6);
indexes.to.delete <- which(y < x);
y <- y[-indexes.to.delete];
I could code an if statement to check if it is indexes.to.deleteempty, but I wonder if there is an easier way?
source
share