Could you please explain why do we have to use [1] in this command and what does it mean in here, local context ? I am beginner and what I know is that mutate is used for creating new column. Is this ([1]) some kind of subsetting ?
Yes, the square brackets are for subsetting the result returned by which(). The which() function takes a comparison and returns the indices where the comparison is true. In the example below, the comparison is x > 4 and it is true in the second and fifth positions. The which() function returns a vector with those two values. The square brackets can then be used to select from the vector that which() returns.
In the mutate() function in my earlier post, this method is used to assign to the Pos column the position of the first column that is greater than the Mean column.