I was wondering if it was possible to do something like this using a loop:
data[data!=1]
data[data!=1&data!=2]
data[data!=1&data!=2&data!=3]
Good afternoon :)
You could try:
data <- c(1,2,3,2,2,1,4,5,2,1)
indices <- 1:3 # or use function seq for more general sequences
for(i in indices){
print(data[!data %in% min(indices):i])
}
If you want to assign back to new vectors, you can try lapply:
obj_list <- lapply(indices, FUN = function(i){
data[!data %in% min(indices):i]
})
obj_list
Is this what you are looking for?