List directories, html-URLs and download-URLs in a GitHub directory.
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)
path | A string formatted as "owner/repo/subdir" or "owner/repo/subdir@branch", e.g.: "maurolepore/ghr/reference@gh-pages". |
---|---|
... | |
regexp | A regular expression (e.g. |
ignore.case | if |
invert | logical. If |
A character string.
path <- "maurolepore/tor/inst/extdata/mixed" # The first call make the request system.time(ghr_ls(path))#> user system elapsed #> 0.020 0.000 0.105#> user system elapsed #> 0.000 0.000 0.001ghr_ls(path, regexp = "[.]csv$")#> [1] "inst/extdata/mixed/csv.csv"ghr_ls(path, regexp = "[.]csv$", invert = TRUE)#> [1] "inst/extdata/mixed/lower_rdata.rdata" #> [2] "inst/extdata/mixed/rda.rda" #> [3] "inst/extdata/mixed/upper_rdata.RData"ghr_ls(path, regexp = "[.]RDATA$", invert = TRUE, ignore.case = FALSE)#> [1] "inst/extdata/mixed/csv.csv" #> [2] "inst/extdata/mixed/lower_rdata.rdata" #> [3] "inst/extdata/mixed/rda.rda" #> [4] "inst/extdata/mixed/upper_rdata.RData"ghr_ls(path, regexp = "[.]RDATA$", invert = TRUE, ignore.case = TRUE)#> [1] "inst/extdata/mixed/csv.csv" "inst/extdata/mixed/rda.rda"# ghr_ls_download_url() and ghr_ls_html_url are similar (d_url <- ghr_ls_download_url(path, regexp = "[.]csv$")[[1]])#> [1] "https://raw.githubusercontent.com/maurolepore/tor/master/inst/extdata/mixed/csv.csv"read.csv(d_url)#> y #> 1 a #> 2 b(h_url <- ghr_ls_html_url(path, regexp = "[.]csv$")[[1]])#> [1] "https://github.com/maurolepore/tor/blob/master/inst/extdata/mixed/csv.csv"