I would like to use the grepl() function to determine whether a vector of characters is matched with a pattern and based on that pattern concatenate characters within the vector. For example:
vec <- c("a","b","a","c","a","c","a","b") 
grepl("[a]", vec)
TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
I would like the all of the values following the TRUE to be binded together until the next TRUE so that the outcome of this would be a vector that looks like:
"ab", "ac", "ac", "ab"
Thanks for any thoughts.
 
     
    