read_list | R Documentation |
Supply a list of data sets and the function to read the datasets. For
example, to read in .csv
files, use readr::read_csv
. This function comes
from Bruno Rodrigues' website and credit goes to him.
If you prefer not to have the datasets in a list, but rather import them into
the global environment, then use read_list2
.
read_list(list_of_datasets, read_func)
read_list2(list_of_datasets, read_func, envir = .GlobalEnv)
list_of_datasets |
A character vector with names of data sets to read. |
read_func |
Function to read the data sets. |
envir |
Environment to assign data frames to. Default is |
A list of data sets
http://www.brodrigues.co/blog/2016-07-26-read-a-lot-of-datasets-at-once-with-r/
## Not run:
library(dplyr)
library(stringr)
library(readr)
csv_path <- "C:/Users/latour/Dropbox/repos/lamisc/inst/extdata"
(data_files <- list.files(path = csv_path,
pattern = ".csv"))
setwd(csv_path)
#### read_list --------------------------------
list_of_data_sets <- read_list(list_of_datasets = data_files,
read_func = readr::read_csv)
dplyr::glimpse(list_of_data_sets)
#### read_list2 --------------------------------
read_list2(list_of_datasets = data_files,
read_func = readr::read_csv)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.