Re: [R] Searching within a ch. string

2009-05-14 Thread Gabor Grothendieck
If the input is "gdfsa-sdhchc99-88" then assuming you only want "88" but not "99" then if s is the vector of words that we already computed: s[regexpr("^[0-9]+", s) > 0] or that could be combined with the strapply solution into one line: > strapply("gdfsa-sdhchc99-88", "\\w+", ~ if (regexpr("^[0

Re: [R] Searching within a ch. string

2009-05-14 Thread Wacek Kusnierczyk
RON70 wrote: > Thanks for these suggestions. However I have one more question. Is there any > way to extract only numbers? For example I want to extract only "88" in my > example. > if you have just one integer number represented in a single string, here's one way go: strings = c('foo 1',

Re: [R] Searching within a ch. string

2009-05-14 Thread RON70
Thanks for these suggestions. However I have one more question. Is there any way to extract only numbers? For example I want to extract only "88" in my example. Regards, MUHC-Research wrote: > > Hi Ron, > > Look up the grep() function. > > Cheers, > > -- > *Luc Villandré* > /Biostatistician

Re: [R] Searching within a ch. string

2009-05-11 Thread Luc Villandre
Hi Ron, Look up the grep() function. Cheers, -- *Luc Villandré* /Biostatistician McGill University Health Center - Montreal Children's Hospital Research Institute/ RON70 wrote: Hi all, is there any function to find some words in a character-string? For example suppose the string is : "gdfsa-s

Re: [R] Searching within a ch. string

2009-05-11 Thread Gabor Grothendieck
The following is TRUE if the indicated string is found: regexpr("sdhch", "gdfsa-sdhchc-88") > 0 See ?regexpr Either of the next two will break up a string into words. The first needs to know the delimiters whereas the second needs to know the contents: > strsplit("gdfsa-sdhchc-88", "\\W+")[[1]]

Re: [R] Searching within a ch. string

2009-05-11 Thread Duncan Murdoch
On 5/11/2009 10:07 AM, RON70 wrote: Hi all, is there any function to find some words in a character-string? For example suppose the string is : "gdfsa-sdhchc-88", now I want to find whether this string contains "sdhch". Is there any R function to do that? See ?grep. There are several functions

[R] Searching within a ch. string

2009-05-11 Thread RON70
Hi all, is there any function to find some words in a character-string? For example suppose the string is : "gdfsa-sdhchc-88", now I want to find whether this string contains "sdhch". Is there any R function to do that? Regards, -- View this message in context: http://www.nabble.com/Searching-w