R/run_split.R

Defines functions run_split

Documented in run_split

#' Split a String Into Run Chunks
#' 
#' Splits a string into a vector of runs.
#' 
#' @param x A string.
#' @return Returns a list of vectors. 
#' @seealso \code{\link[qdapTools]{loc_split}},
#' \code{\link[qdapTools]{split_vector}}
#' @author Robert Reed and Tyler Rinker <[email protected]@gmail.com>.
#' @references \url{http://stackoverflow.com/a/24319217/1000343} 
#' @export
#' @examples
#' run_split(c("122333444455555666666", NA, "abbcccddddeeeeeffffff"))
run_split <- function(x) {
    strsplit(x, "(?<=(\\w))(?!\\1)", perl = TRUE)
}

Try the qdapTools package in your browser

Any scripts or data that you put into this service are public.

qdapTools documentation built on May 2, 2019, 5:53 a.m.