Re: [R] regular expression help to extract specific strings from text

2010-04-01 Thread Tony B
Thank you guys, both solutions work great! Seems I have two new packages to investigate :) Regards, Tony Breyal On 31 Mar, 14:20, Tony B wrote: > Dear all, > > Lets say I have the following: > > > x <- c("Eve: Going to try something new today...", "Adam: Hey @Eve, how are > > you finding R? #rs

Re: [R] regular expression help to extract specific strings from text

2010-03-31 Thread hadley wickham
On Wed, Mar 31, 2010 at 8:20 AM, Tony B wrote: > Dear all, > > Lets say I have the following: > >> x <- c("Eve: Going to try something new today...", "Adam: Hey @Eve, how are >> you finding R? #rstats", "Eve: @Adam, It's awesome, so much better at >> statistics that #Excel ever was! @Cain & @Abl

Re: [R] regular expression help to extract specific strings from text

2010-03-31 Thread Gabor Grothendieck
strapply in gsubfn can extract matches based on content which seems to be what you want: library(gsubfn) f <- function(...) sapply(list(...), paste, collapse = ", ") DF <- data.frame(x, Source = strapply(x, "^(\\w+):", c, simplify = f), Mentions = strapply(x, "@(\\w+)", c, simpli

[R] regular expression help to extract specific strings from text

2010-03-31 Thread Tony B
Dear all, Lets say I have the following: > x <- c("Eve: Going to try something new today...", "Adam: Hey @Eve, how are > you finding R? #rstats", "Eve: @Adam, It's awesome, so much better at > statistics that #Excel ever was! @Cain & @Able disagree though :(", "Adam: > @Eve I'm sure they'll so