I have the below working code in Javascript for shifting strings. I need the same in R, but i am not able to find out any proper solution. can someone please help me in this