This is the question "R":
Suppose I have a three-letter vector, for example: “BBSSHHSRBSBBS,” which I like to find is the position of the first “S” that appears after the sequence “B”. For example, in the vector above, the first “S” that appears after the sequences “B” will appear in 3rd place of 10th place and last place (13)
I can do it trivially with loops, but I like to find out if there is a way to do this in "R" without looping at all.
The function should receive the vector R as input and return the position vector "S" as the output
Thanks,
source share