join vs merge

2,926 views
Skip to first unread message

Roger Bos

unread,
Jan 30, 2014, 3:56:01 PM1/30/14
to manip...@googlegroups.com
All,

Can anyone confirm if join() is better than merge()?  I am assuming it is because why else write a new function when there is a function is base R to do it.  My second question is why is join not exported by dplyr?  It seems that if I want to use join I have to load plyr and dplyr.  I just wanted to confirm that that is indeed the case.

Thanks,

Roger

Hadley Wickham

unread,
Jan 30, 2014, 4:01:04 PM1/30/14
to Roger Bos, manipulatr
join is a plyr function. dplyr has inner_join, left_join, semi_join and anti_join.  The advantages of the dplyr versions over merge are:

* rows are kept in existing order
* much faster
* tells you what keys you're merging by (if you don't supply)
* also work with database tables.

Hadley


--
You received this message because you are subscribed to the Google Groups "manipulatr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to manipulatr+...@googlegroups.com.
To post to this group, send email to manip...@googlegroups.com.
Visit this group at http://groups.google.com/group/manipulatr.
For more options, visit https://groups.google.com/groups/opt_out.



--
http://had.co.nz/

Roger Bos

unread,
Jan 30, 2014, 4:38:34 PM1/30/14
to manip...@googlegroups.com
Do those advantages apply to plyr::join or only dplyr::join?  I am not sure which version I am using as when I don't load the plyr package the join function cannot even be found.

Thanks,

Roger

Hadley Wickham

unread,
Jan 30, 2014, 4:45:26 PM1/30/14
to Roger Bos, manipulatr
There's only plyr::join.  plyr::join has the same advantages as dplyr::inner_join etc, except that it's nowhere near as fast.

Hadley


--
You received this message because you are subscribed to the Google Groups "manipulatr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to manipulatr+...@googlegroups.com.
To post to this group, send email to manip...@googlegroups.com.
Visit this group at http://groups.google.com/group/manipulatr.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages