[R] problem with comparing a part of string with whole string
venkata kirankumar
kiran4u2all at gmail.com
Fri Feb 20 07:19:43 CET 2009
Hi ,
i just attached one file to this mail which contains one modal of my data
and there i have to search for the rows which contains "SPECIMENTYP %in%
"ADIPOSE TISSUE""
and the rows which contains " "PRESERVED" in ORGCHARRES
for that i tried with
" r<-subset(rr,SPECIMENTYP %in% "ADIPOSE TISSUE" & grep("IN
DIAMETER",rr$ORGCHARRES),select=c(SPECIMENTYP,ORGCHARRES))"
but i got only the rows having "ADIPOSE TISSUE" in "SPECIMENTYP"
can anyone suggest any of the way for comparision of this type
thanks in advance
On Thu, Feb 19, 2009 at 6:26 PM, Petr PIKAL <petr.pikal at precheza.cz> wrote:
> 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<http://www.r-project.org/posting-guide.html>
> > and provide commented, minimal, self-contained, reproducible code.
>
>
More information about the R-help
mailing list