I wanted to extract my interested rows from a dataframe. I used:
grep(list$ID, dataframe$ID, value=T) #list contains a list of my interested
IDs
I got one match in return, which is the very first ID in list. It seems the
matching process just stopped, once the first match was found.
David
I think you want to use either 'match' or '%in%'
x - dataframe$ID %in% list$ID # TRUE if it is in list
On Wed, Aug 5, 2009 at 5:36 AM, Rnewbiexua...@yahoo.com wrote:
I wanted to extract my interested rows from a dataframe. I used:
grep(list$ID, dataframe$ID, value=T) #list contains a list
the problem in my case is that some of the cells in dataframe$ID contain
multiple IDs, but in list$ID there is only one ID in each cell, so some of
the IDs cannot be matched if using the fucntion 'match' or '%in%'
jholtman wrote:
I think you want to use either 'match' or '%in%'
x -
Perhaps
intersect()
or
merge()
will help. But, like others, I find it difficult to understand
exactly what you want. I'd suggest providing a short example with
actual ID values.
-Don
At 2:36 AM -0700 8/5/09, Rnewbie wrote:
I wanted to extract my interested rows from a dataframe. I used:
...@yahoo.com, r-help@r-project.org
Envoyé: Mercredi 5 Août 2009 16h49:58 GMT +01:00 Amsterdam / Berlin / Berne /
Rome / Stockholm / Vienne
Objet: Re: [R] problem with pattern matching
Perhaps
intersect()
or
merge()
will help. But, like others, I find it difficult to understand
exactly what
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of jim holtman
Sent: Wednesday, August 05, 2009 5:23 AM
To: Rnewbie
Cc: r-help@r-project.org
Subject: Re: [R] problem with pattern matching
I think you want to use either 'match
...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of jim holtman
Sent: Wednesday, August 05, 2009 5:23 AM
To: Rnewbie
Cc: r-help@r-project.org
Subject: Re: [R] problem with pattern matching
I think you want to use either 'match' or '%in%'
x - dataframe$ID %in% list$ID
I have a list of IDs like this:
AB1234
AB4567
AB8901
In my dataset, there are IDs like this:
AB
AB /// AB1234
AB4567 /// AB8901 /// AB
I used grep(list$ID, dataset$ID, value=T)
It returned only one match, which was the very first match AB ///
AB1234. It seems once the first
dear all,
I got a problem with pattern matching using grep. I extracted a list of
characters from a data frame, and I tried to match this list of characters
to a column from another data frame. In return, I got only one match, but
there should be far more matches. Any ideas what has gone wrong?
On Aug 4, 2009, at 11:16 AM, Rnewbie wrote:
dear all,
I got a problem with pattern matching using grep. I extracted a list
of
characters from a data frame, and I tried to match this list of
characters
to a column from another data frame. In return, I got only one
match, but
there
10 matches
Mail list logo