It might be helpful for you to know how to properly format code and console output that you post here. Using proper code formatting makes the site easier to read, prevents confusion (unformatted code can get garbled by the forum software ), and is generally considered the polite thing to do. Check out this FAQ to find out how — it's as easy as the click of a button! :
in that case, i will literally takes the values in T. From the looks of it, you want i to be an integer, so you need to define that sequence separately: for(i in 1:T) for example.
Also,
R does not have a by option in for(). So that means you need to modify directly the 1:n to make it have the index you want.
this is not required in R, but implied by the }.
return() is only meaningful within a function.
this one doesn't work, as the value of i gets redefined when you write for ( i in .... So you really need to define first the vector of indices you want to loop on, then start the loop.