Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marcelotournier/2f7cc8a757221938e47b03e409efd32f to your computer and use it in GitHub Desktop.
Save marcelotournier/2f7cc8a757221938e47b03e409efd32f to your computer and use it in GitHub Desktop.
utils.R
# 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