Re: [R] Basic data structures

2008-08-10 Thread Satoshi Takahama
Suppose I want to have a regexp match against a string, and return all the matching substrings in a vector of strings. regexp <- "[ab]+" strlist <- c( "abc", "dbabddadd", "aaa" ) matches <- gregexpr(regexp,strlist) With this input, I'd want to return list( list("ab"), list("ab", "a"), li

Re: [R] Basic data structures

2008-08-10 Thread Gabor Grothendieck
Try this: regexp <- "[ab]+" strlist <- c( "abc", "dbabddadd", "aaa" ) library(gsubfn) s <- strapply(strlist, regexp) s # compactly show 1st few in ea component str(s) See gsubfn home page at http://gsubfn.googlecode.com On Sun, Aug 10, 2008 at 5:00 PM, Stavros Macrakis <[EMAIL

[R] Basic data structures

2008-08-10 Thread Stavros Macrakis
I'm new to R and very excited about its possibilities. But I'm struggling with some very simple things, probably because I haven't found the correct documentation. Here's a simple example which illustrates several of my problems. Suppose I want to have a regexp match against a string, and return