How to access vector elements in a for loop using R

r

#1

I have created a vector x<-c(2,4,6,8,10) and I have used the for loop

for(i in x){
}

but I am getting
i
1 2
2 4
3 8
4 10
5 12
6 NA
7 NA
8 NA
9 NA
10 NA
11 NA
12 NA


#2

The question seems unclear.
What exactly are the contents of the loop?

   x<-c(2,4,6,8,10)
   for(i in x)
    {
        print(i)
    }

gives the output as expected.

and

for(i in x){
}

outputs
[1] 10
as expected.