The meaning of Loop : I saw a loop in a demo code:

````
b <- 3
n <- 4

set.seed(1)

(i <- sample(rep(1:n, 
                 b)) )      
(g <- rep(1:b, 
          each=n) )      

(x <- rnorm(n) )           

m  <- rep(NA, max(g))      

for (j in 1:max(g) ) {      
  k    <- i[ g == j ]     
  m[j] <- mean(x[k])      
  print (j)
  print (k)
}   

````
The max(g) = 3, so the loop run 3 times. but I don't understand the second row of the loop ` k  <- i[ g == j ] `. What is the meaning of this part?  Thank you!