[R] Problem merging data frames and duplicates
Frank Burbrink
burbrink666 at gmail.com
Wed May 27 12:20:40 CEST 2015
Thanks Bill,
However, unique(merge(x, y, by = 1, all=T)) is giving me:
state locus.x locus.y
1 AR 5 2
2 AR 5 3
3 AR 6 2
4 AR 6 3
5 IL 1 1
9 LA 2 NA
11 MS 3 NA
12 MS 4 NA
13 TN NA 3
14 TN NA 4
This has AR repeated twice and the normal double IL and LA now only listed
singly.
What I am hoping for is something like this:
state locus.x locus.y
1 AR 5 2
4 AR 6 3
7 IL 1 1
8 IL 1 1
9 LA 2 NA
10 LA 2 NA
11 MS 3 NA
12 MS 4 NA
13 TN NA 3
14 TN NA 4
On Wed, May 27, 2015 at 3:53 AM, William Michels <wjm1 at caa.columbia.edu>
wrote:
> Hi Frank,
>
> It looks like you're very close. I think you want:
>
> unique(merge(x, y, by = 1, all=T))
>
> Gabor Grothendieck's sqldf package is very useful if you're more
> comfortable with SQL-type syntax, see:
>
> https://github.com/ggrothendieck/sqldf
>
> Best Regards,
>
> William (Bill) Michels, Ph.D.
>
>
>
> On Tue, May 26, 2015 at 5:12 PM, Frank Burbrink
> <burbrink666 at gmail.com> wrote: <SNIP>
>
--
*************************************
*Frank T. Burbrink, Ph.D.*
*Professor*
*Biology Department*
*6S-143*
*2800 Victory Blvd.*
*College of Staten Island/CUNY*
*Staten Island, New York 10314*
*E-Mail:Frank.Burbrink at csi.cuny.edu <E-Mail%3AFrank.Burbrink at csi.cuny.edu>*
*Phone:718-982-3961*
*Web Page: http://scholar.library.csi.cuny.edu/~fburbrink/
<http://scholar.library.csi.cuny.edu/%7Efburbrink/>*
*************************************
*Chair *
*Ecology, Evolutionary Biology, and Behavior*
*Doctoral Subprogram*
*Biology Program*
*City University of New York *
*Graduate Center*
*365 Fifth Avenue*
*New York, NY 10016-4309*
************************************
[[alternative HTML version deleted]]
More information about the R-help
mailing list