read_repo | R Documentation |
This utility allows files from a GitHub repository to be read in bulk. The pattern for file names to read (and sub-directories to traverse) can be arbitrarily defined using a regular expression.
read_repo( repo, branch = "master", pattern = NULL, to_tibble = FALSE, .f = readr::read_csv, n_files = NULL, ... )
repo |
Name of the GitHub repository containing the files |
branch |
Name of the branch of the GitHub repository containing the files; default is |
pattern |
Pattern to match file names to be returned; accepts regex |
to_tibble |
Boolean indicating whether or not the function should attempt to return a |
.f |
Function to read each file whose name complies to |
n_files |
Maximum number of files to read in |
... |
Additional arguments passed to the |
Starting with a call to the GitHub API, this function returns a list of files, which are then filtered to include only those that match the regular expression in the "pattern" argument. The function then internally constructs the raw content URLs and then applies the read function (".f") to each path.
NOTE: The API call is unauthenticated. GitHub API request rate limits apply. For specifics, review the GitHub API documentation.
Contents of the files in the repository that have read using ".f" function supplied. If to_tibble = TRUE
then the function will try to stack results on top of each other and return a tibble
. If to_tibble = FALSE
then the returned object will be a list with as many elements as there are files in the repository that match the "pattern" argument.
## Not run: read_repo(repo = "cdcepi/Flusight-forecast-data", branch = "master", pattern = "data-forecasts/.*/.*\\.csv", to_tibble = TRUE, .f = readr::read_csv, n_files=10, col_types="DcDccdd", progress=FALSE) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.