SHARE
TWEET

Untitled

a guest Jun 24th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top