For a string such as:
text <- "abcdefghijklmnopqrstuvwxyz"
I would like to cut a string into substrings, for example a length of 10, and save the remainder:
"abcdefghij" "klmnopqrst" "uvwxyz"
All the methods that I know for creating substrings do not give me a residual substring with 6 characters. I have tried answers to previous similar questions, such as:
> substring(text, seq(1, nchar(text), 10), seq(10, nchar(text), 10)) [1] "abcdefghij" "klmnopqrst" ""
Any advice on how to get all the substrings of the desired length and any remaining strings would be greatly appreciated.
source share