read_file_from_repo: Read a file from a (personal) GitHub repository

View source: R/read_file_from_repo.R

read_file_from_repoR Documentation

Read a file from a (personal) GitHub repository

Description

read_file_from_repo reads a file from a GitHub repository. Both public and personal repositories are supported.

Usage

read_file_from_repo(
  repo,
  path,
  token_key,
  user = "rethinkpriorities",
  private = FALSE
)

Arguments

repo

A character string specifying the GitHub repository.

path

A character string specifying the file path in the GitHub repository.

token_key

A character string specifying the key to the GitHub personal access token (PAT), stored using the keyring package.

user

A character string specifying the GitHub user name. By default this is 'rethinkpriorities'.

private

A boolean value indicating whether the GitHub repository is a private repository or not. The default is FALSE.

Details

This function relies on the keyring package to retrieve a stored GitHub Personal Access Token (PAT) to access private repositories. This is safer than storing the PAT in the environment.

Examples

## Not run: 
data <- read_file_from_repo(
  repo = "ea-data", path = "data/edited_data/sexual_orientation.csv", 
  private = TRUE, token_key = "github-PAT"
)

## End(Not run)


rethinkpriorities/rp-r-package documentation built on Jan. 7, 2023, 10:11 p.m.