Fixed implementation of R command.

It almost works perfectly now! I was popping instead of shifting the array
:\