Hey, I am struck on a problem that requires to a vector for the given condition. But as I've come across, I think the 'for loop' loops over from the beginning. The example will make it much clearer.
numbers <- vector("numeric",length=4)
for (i in c(2,7,9,12)){
numbers[[i]] <- i
print(i)
}
numbers
Output looks like:
What I want is to create a vector that looks something like:
[1] 2 7 9 11
Is there a way to do so? Please help me out.