Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. stringslider <- function(stri, l) {
  2. # Returns a vector of unique strings of length l extracted from string
  3. # works through a sliding window from left to right. Checks if each returned
  4. # string is of length l.
  5. #
  6. # Args:
  7. # stri: A string from on which the extraction occurs.
  8. # l: length of the extracted strings.
  9. #
  10. # Returns:
  11. # A vector of extracted strings with length l.
  12. strle <- nchar(stri)
  13. i <- 1
  14. subc <- c()
  15.  
  16. while (i + l - 1 <= strle) {
  17. subc <- c(subc,
  18. substr(stri,
  19. start = i,
  20. stop = i + l - 1))
  21. i <- i + 1
  22. }
  23. return(subc)
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement