I have figured out a cheesy work around since these problems have to do with not having unique identifiers for the States:
1) Append a unique identifier to each state such that both AR becomes ARa and ARb 2) run the normal merge(x,y,by=1, all=T) 3) Use subst to cut the appended identifiers. While this is clunky I can just write a function to do it all at once. On Wed, May 27, 2015 at 6:20 AM, Frank Burbrink <burbrink...@gmail.com> wrote: > 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 <w...@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 >> <burbrink...@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.burbr...@csi.cuny.edu <e-mail%3afrank.burbr...@csi.cuny.edu>* > *Phone:718-982-3961 <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* > ************************************ > -- ************************************* *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.burbr...@csi.cuny.edu <e-mail%3afrank.burbr...@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]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.