Created
July 19, 2021 18:01
-
-
Save marcelotournier/2f7cc8a757221938e47b03e409efd32f to your computer and use it in GitHub Desktop.
utils.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Scripts em R para ajudar a abstrair algumas rotinas que rodo sempre. | |
# Para carregar: Cole em um arquivo `utils.R` e use `source("./utils.R")` | |
# no seu script. | |
library(data.table) | |
library(dplyr) | |
library(purrr) | |
# Read multiple files into a single Tibble | |
read_multiple_files <- function(directory, filetype="csv") { | |
file_pattern <- paste("*.", filetype, sep="") | |
tbl <- | |
directory %>% | |
list.files(., pattern=file_pattern) %>% | |
paste(directory, ., sep="") %>% | |
map_df(~fread(.)) %>% | |
as_tibble(.) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment