ghr_ls: List directories, html-URLs and download-URLs in a GitHub...

Description Usage Arguments Value Examples

View source: R/ghr_ls.R

Description

List directories, html-URLs and download-URLs in a GitHub directory.

Usage

1
2
3
4
5
6
7
ghr_ls(path, ..., regexp = NULL, ignore.case = FALSE, invert = FALSE)

ghr_ls_html_url(path, ..., regexp = NULL, ignore.case = FALSE,
  invert = FALSE)

ghr_ls_download_url(path, ..., regexp = NULL, ignore.case = FALSE,
  invert = FALSE)

Arguments

path

A string formatted as "owner/repo/subdir" or "owner/repo/subdir@branch", e.g.: "maurolepore/ghr/reference@gh-pages".

...

Arguments passed to gh::gh() via ghr_get().

regexp

A regular expression (e.g. [.]csv$) passed on to grep() to filter paths.

ignore.case

if FALSE, the pattern matching is case sensitive and if TRUE, case is ignored during matching.

invert

logical. If TRUE return indices or values for elements that do not match.

Value

A character string.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
path <- "maurolepore/tor/inst/extdata/mixed"

# The first call make the request
system.time(ghr_ls(path))
# Takes no time because the first call is memoised
system.time(ghr_ls(path))

ghr_ls(path, regexp = "[.]csv$")
ghr_ls(path, regexp = "[.]csv$", invert = TRUE)

ghr_ls(path, regexp = "[.]RDATA$", invert = TRUE, ignore.case = FALSE)
ghr_ls(path, regexp = "[.]RDATA$", invert = TRUE, ignore.case = TRUE)

# ghr_ls_download_url() and ghr_ls_html_url are similar
(d_url <- ghr_ls_download_url(path, regexp = "[.]csv$")[[1]])
read.csv(d_url)

(h_url <- ghr_ls_html_url(path, regexp = "[.]csv$")[[1]])
if (interactive()) {
  utils::browseURL(h_url)
}

maurolepore/ghr documentation built on May 18, 2019, 12:26 p.m.