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

jim holtman jholtman at gmail.com
Thu Feb 19 13:53:56 CET 2009


'grep' will tell you if there is a match in the string;

> x <- c("*RIGHT, EPICARDIUM: FOCUS, GRAY-WHITE, SINGLE, APPROX 0.6 CM IN DIAMETER*.","*MEDULLRY TUMOR BENIGN,TYP PHEOCHROMOCYTOMA*")
> grep("GRAY-WHITE", x)
[1] 1
> grep("TUMOR BENIGN", x)
[1] 2

On Thu, Feb 19, 2009 at 7:39 AM, venkata kirankumar
<kiran4u2all at gmail.com> wrote:
> 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
>
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list