R tip: Read and bind files

First post in my new Quarto blog
Rstats
Author
Published

May 17, 2022

R tip - This is how to read and bind data from many excel files:

```{r}
#| warning: false
#| message: false

library(tidyverse)
library(readxl)

files_list <- list.files(path = ".",
                         pattern = "^plan(.)*.xlsx",
                         full.names = TRUE)

df <- 
  files_list %>% 
  map(read_excel) %>% 
  reduce(bind_rows)
```

I love how the reduce and map functions make everything simpler.

Citation

BibTeX citation:
@misc{abreu2022,
  author = {Abreu, Marcos},
  title = {R tip: Read and bind files},
  date = {2022-05-17},
  url = {https://abreums.github.io/posts/2022-05-17-r-tip-read-and-bind-files/},
  langid = {pt-br}
}
For attribution, please cite this work as:
Abreu, Marcos. 2022. “R tip: Read and bind files.” May 17, 2022. https://abreums.github.io/posts/2022-05-17-r-tip-read-and-bind-files/.