Substring In Cpp String Methods In R