I have implemented the combination of for loop and if else condition in R
for (i in 1:n) {
if(some condition) {
some code
else {
some code
}
}
The condition is the i-th element of a vector is lower than a certain threshold. And I perform some different operation on it depending whether it is true or false. The vector is very long and I would like to know if there is a way to perform this without using for loop.