Select every other element from a vector

remove[c(TRUE, FALSE)] will do the trick. How it works? If logical vectors are used for indexing in R, their values are recycled if the index vector is shorter than the vector containing the values. Here, the vector remove contains ten values. If the index vector c(TRUE, FALSE) is used, the actual command is: remove[c(TRUE, FALSE, … Read more