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
McGill
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', '2
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-9]*$, x) 0)
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:
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
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]]
[1]
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 :
7 matches
Mail list logo