Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206736

Merging a list of data.frames with purrr (reduce/reduce2)

$
0
0

This is my data:

list_of_data <- list(mtcars[1:26,], mtcars[4:22,], mtcars[3:15,])

I want to merge the all dataframes by their rownames.

Merging a lot of data.frames

I know that Reduce comes pretty handy for a problem like this, but I am not able to get in inside my purrr workflow. Can anyone help me?

I am even not sure if reduce or reduce2 might be suited to get it work. This was my try but it does not work:

list_of_data %>%
    map(~select(.x, c(cyl, wt))) %>%
    reduce2(~merge(.x, .y,  all=TRUE))

Viewing all articles
Browse latest Browse all 206736

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>