Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stringslider <- function(stri, l) {
- # Returns a vector of unique strings of length l extracted from string
- # works through a sliding window from left to right. Checks if each returned
- # string is of length l.
- #
- # Args:
- # stri: A string from on which the extraction occurs.
- # l: length of the extracted strings.
- #
- # Returns:
- # A vector of extracted strings with length l.
- strle <- nchar(stri)
- i <- 1
- subc <- c()
- while (i + l - 1 <= strle) {
- subc <- c(subc,
- substr(stri,
- start = i,
- stop = i + l - 1))
- i <- i + 1
- }
- return(subc)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement