A beginner question…
I have a list like this:
x <- c("aa=v12, bb=x21, cc=f35", "xx=r53, bb=g-25, yy=h48", "nn=u75, bb=26, gg=m98")
(but many more lines)
I need to extract what is between “bb=” and “,”. I.e. I want:
x21
g-25
26
Having read many similar questions here, I suppose it is stringr with str_extract I should use, but somehow I can’t get it to work. Thanks for all help.
/Chris
strapplyin the gsubfn package can do that. Note that[^,]*matches a string of non-commas.strapplyextracts the back referenced portion (the part within parentheses):If there are several
xvectors then provide them in a list like this: