[R] Odp: problem with comparing a part of string with whole string

Petr PIKAL petr.pikal at precheza.cz
Thu Feb 19 13:56:58 CET 2009


Hi

r-help-bounces at r-project.org napsal dne 19.02.2009 13:39:42:

> Hi all,
> 
> I got one problem with comparing strings like if any string is like
> 
> "*RIGHT, EPICARDIUM: FOCUS, GRAY-WHITE, SINGLE, APPROX 0.6 CM IN 
DIAMETER*."
> 
> and i have to compare       "*GRAY-WHITE*"        with the above string
> 
> or otherwise   i have to compare       " *TUMOR BENIGN*"       this 
string
> with
> 
> "*MEDULLRY TUMOR BENIGN,TYP PHEOCHROMOCYTOMA*"
> 
> i tried with split and compare but its not working

Work for regular expressions?

vec="*RIGHT, EPICARDIUM: FOCUS, GRAY-WHITE, SINGLE, APPROX 0.6 CM IN 
DIAMETER*."
test="GRAY-WHITE"
regexpr(test, vec)
[1] 28
attr(,"match.length")
[1] 10

Regards
Petr


> 
> can any one suggest how can i compare these type of Strings
> 
> thanks in advance
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list