?merge

> merge(A,B)
  C1  C2
1  A 200


On Thu, May 7, 2009 at 2:19 AM, Raghavan, Nandini [PRDUS] <
nragh...@its.jnj.com> wrote:

> Hello,
>
>
>
> I am trying to extract a subset of a dataframe A (2 columns) by
> extracting all entries in A (several repeated entries) that match
> dataframe B in both columns.  For example, part of A and B are shown
> below.
>
> The following does not seem to work correctly. This only seems to select
> on the first component and all instances of the second.
>
> ind <- A$C1 %in% B[,1] & A$C2 %in% B[,2]
>
> Any suggestions as to how to do this in general (even for matches in
> multiple columns) would be appreciated.
>
>
>
> Regards,
>
> Nandini
>
>
>
>
>
> A:
>
>   C1   C2
>
> 1   F 1500
>
> 2   P  120
>
> 4   F  250
>
> 5   I  200
>
> 6   D 2010
>
> 7   F 1000
>
> 8   V    0
>
> 9   F 2100
>
> 10  F  500
>
> 11  E 1800
>
> 12  A  500
>
> 13  V    0
>
> 14  I  125
>
> 15  I   30
>
> 16  M  300
>
> 17  D   75
>
> 18  V  500
>
> 19  A  200
>
> 20  M 1000
>
> 21  P  225
>
>
>
> B:
>
>  C1   C2
>
> 1   A  200
>
> 2   A  600
>
> 3   A 1500
>
> 4   B  100
>
> 5   B 1000
>
> 6   C 5000
>
> 7   C  225
>
> 8   C  150
>
> 9   C  150
>
> 10  C  200
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>



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

What is the problem that you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to