[R] strsplit, keeping delimiters

hadley wickham h.wickham at gmail.com
Sat Jun 14 16:22:29 CEST 2008


On Sat, Jun 14, 2008 at 12:55 AM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
> Try this:
>
>> library(gsubfn)
>> x <- "A: 123 B: 456 C: 678"
>> strapply(x, "[^ :]+[ :]|[^ :]+$")
> [[1]]
> [1] "A:"   "123 " "B:"   "456 " "C:"   "678"
>
> and check out the gsubfn home page at:
>
> http://gsubfn.googlecode.com

Thanks Gabor!
Hadley

-- 
http://had.co.nz/



More information about the R-help mailing list