---
title: "Merge multiple data frames with `multiMerge`"
author: "Florian Detsch"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Merge multiple data frames with `multiMerge`}
  %\VignetteEngine{knitr::knitr}
  %\VignetteEncoding{UTF-8}
---

```{r pkg, echo=FALSE, message=FALSE}
library(Orcs)
```

Merging multiple data frames in R is anything but straightforward and usually involves confusing loop structures. `multiMerge` elegantly avoids such bewildering code chunks by invoking `Reduce` upon a list of data frames. The function also features a set of auxiliary parameters that are passed on to `merge`. Note that the code is mainly taken from a related [blog post in StackOverflow](https://stackoverflow.com/questions/8091303/merge-multiple-data-frames-in-a-list-simultaneously). 

```{r mergeList, eval=TRUE}
## sample data
set.seed(10)
ls_df <- list(data.frame(a = 1:10, b = 1:10),
              data.frame(a = 5:14, c = 11:20),
              data.frame(a = sample(20, 10), d = runif(10)))

## merge data frames in one go
merge(ls_df, by = "a", all = TRUE)
```
