Skip to content

problem with comparing a part of string with whole string

5 messages · venkata kirankumar, jim holtman, PIKAL Petr +1 more

#
'grep' will tell you if there is a match in the string;
[1] 1
[1] 2

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

  
    
#
Hi

r-help-bounces at r-project.org napsal dne 19.02.2009 13:39:42:
DIAMETER*."
string
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
http://www.R-project.org/posting-guide.html
#
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:

            
#
Imagine the following data of noises that people make, and you want to know
who makes the noise "blub."

data=data.frame(rbind(c("blah, boo, blub"),c("blabber, baeh,
blib"),c("quack, cheer, blub")))
names(data)=c("noises")
data

searchTerm="blub"

#The first gives a list of all noises that people make
#who also make the "blub" noise (among others)
data$sound[grep(searchTerm,data$noises)]

# This gives the index (row) number of the observation  
# of who makes the "blub" noise
which(data$noises==data$noises[grep(searchTerm,data$noises)])

Is that what you want?
Daniel


-------------------------
cuncta stricte discussurus
-------------------------

-----Urspr?ngliche Nachricht-----
Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im
Auftrag von venkata kirankumar
Gesendet: Friday, February 20, 2009 1:20 AM
An: Petr PIKAL
Cc: r-help at r-project.org
Betreff: Re: [R] problem with comparing a part of string with whole string

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: