Giter Club home page Giter Club logo

Comments (5)

dchiu911 avatar dchiu911 commented on May 25, 2024

In essence, what I wanted to achieve was a wrapper for merge(x1, x2, all = TRUE)
but it seems like merge_df() is doing something a little different:

x1 <- efc %>% dplyr::select(1:5) %>% slice(1:10)
x2 <- efc %>% dplyr::select(3:7) %>% slice(1:10)
merge(x1, x2, all = TRUE) %>% dim()
# [1] 10  7
merge_df(x1, x2) %>% dim()
# [1] 20  7

from sjmisc.

sjPlot avatar sjPlot commented on May 25, 2024

Ok, this was a wrong description in the docs of merge_df(). I think I had an example where base merge() did the same as merge_df(), but maybe I was wrong or using a very specific example, which yielded the same results in both merge() and merge_df().

merge_df() intends to "append" two data frames, thus it is an additional feature to dplyr's join_*() functions. So, it's working as intended, just the description with merge() was wrong. I fixed the docs.

from sjmisc.

sjPlot avatar sjPlot commented on May 25, 2024

btw, dplyr's join-function preserve all label attributes, so you can use these if you need other join-operations.

from sjmisc.

dchiu911 avatar dchiu911 commented on May 25, 2024

Thanks for the clarifications! Yes I used dplyr::left_join() to much avail.

from sjmisc.

sjPlot avatar sjPlot commented on May 25, 2024

A typical use case is for example, if you have different country data sets that share a common amount of variables, plus some country specific variables for each country. You can then "merge" these data sets, i.e. all are "row bound", while the specific variables that only appear in one of the data sets is also added as new column, with NA values for those subsets that don't have this variable.

from sjmisc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.