Given the array T = [1, 2, 3, 4, 5, 6], the following pseudocode

```
n <- length(T)
for i <- 2 to n step 2 do
T[i] <- T[i-1]
end for
return(T)
```

results in:

T = [1, 1, 3, 3, 5, 5]

My goal is to transform the pseudocode to R code:

my code:

```
T = c(1,2,3,4,5,6)
n=length(T)
i=2
for (i in T ,by=2) {
T[i] = T[i-1]
end
}
return(T)
```

further help is appreciated.

thanks