gh_text_files: Read in text files from a GitHub repository

gh_text_filesR Documentation

Read in text files from a GitHub repository


Downloads all text files under the specified path from a GitHub repository via GitHub's GraphQL API and returns a named character vector with the file paths as names and the file contents as values.

This is a simple convenience function combining gh_dir_ls() and gh_text_file().


gh_text_files(owner, name, path = ".", rev = "HEAD", recurse = FALSE)



Repository owner's GitHub user or organization name. A character scalar.


Repository name. A character scalar.


Path to a directory, relative to the repository root. A character scalar.


Git revision expression matching the desired Git tree object, e.g. a branch or tag name or another symbolic reference like "HEAD@{yesterday}" or "HEAD~10". A character scalar.


Whether or not to also include text files in subfolders of path. Enabling this option may result in many API calls and thus produce a significant delay.


Works for both public and private repositories, for the latter you just need to set up a sufficiently authorized GitHub Personal Access Token (PAT).

Note that nothing is returned in case of a binary file, as if no file at all existed under the given path.


A named character vector of length equal to the number of files found under rev:path with the file paths as names and the file contents as values.

See Also

Other GitHub functions: gh_dir_ls(), gh_release_latest(), gh_releases(), gh_text_file()


yay::gh_text_files(owner = "salim-b",
                   name = "pal",
                   path = "tests") |>

# you have to opt-in into directory recursion
yay::gh_text_files(owner = "salim-b",
                   name = "pal",
                   path = "tests",
                   recurse = TRUE) |>

salim-b/yay documentation built on May 17, 2024, 5:24 a.m.