Skip to contents
library(papercheck)
#> 
#> 
#> *******************************************
#> ✅ Welcome to PaperCheck
#> For support and examples visit:
#> https://scienceverse.github.io/papercheck/
#> 
#> ⚠️ This is alpha software; please check any
#> results. False positives and negatives will
#> occur at unknown rates.
#> *******************************************

There are some built-in functions in papercheck for exploring GitHub repositories. You can use these in custom modules.

github_repo

The github functions all work with the following formats for referring to repositories:

  • "{username}/{repo}"
  • "{username}/{repo}.git"
  • "https://github.com/{username}/{repo}.git"
  • "https://github.com/{username}/{repo}/{...}"

The github_repo() function returns the simplified format of. repo name, and an error if the repository in inaccessible.

github_repo("https://github.com/scienceverse/papercheck.git")
#> [1] "scienceverse/papercheck"
github_repo("scienceverse/checkpaper")
#> [1] "unavailable"

github_readme

Get the text of the readme file, regardless of the exact file name (e.g., README vs README.md).

readme <- github_readme("scienceverse/papercheck")

cat(readme)
#> # papercheck
#> 
#> <!-- badges: start -->
#> [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
#> 
#> [![Codecov test coverage](https://codecov.io/gh/scienceverse/papercheck/graph/badge.svg)](https://app.codecov.io/gh/scienceverse/papercheck)
#> <!-- badges: end -->
#> 
#> The goal of papercheck is to automatically check scientific papers for best practices. You can find out more at <https://scienceverse.github.io/papercheck/>.
#> 
#> ## Installation
#> 
#> You can install the development version of papercheck from [GitHub](https://github.com/) with:
#> 
#> ``` r
#> # install.packages("devtools")
#> devtools::install_github("scienceverse/papercheck")
#> ```

github_languages

You can retrieve the number of bytes dedicated to various coding languages, as detected and classified by GitHub.

github_languages("scienceverse/papercheck")
#>     language   bytes
#> 1       HTML 2827261
#> 2          R  437934
#> 3        TeX   25601
#> 4       AMPL    7578
#> 5     Python    6986
#> 6        CSS    3358
#> 7 JavaScript    1018
#> 8       SCSS      19

github_files

You can get a list of file names, their path, size, file extension, and a guess at their type.

By default, you just retrieve the files and directories in the base directory, non-recursively.

github_files("scienceverse/papercheck")
#>                name             path  size          ext   type
#> 1            _stuff           _stuff     0                 dir
#> 2           .github          .github     0       github    dir
#> 3        .gitignore       .gitignore   301    gitignore config
#> 4     .Rbuildignore    .Rbuildignore   199 rbuildignore   file
#> 5              data             data     0                 dir
#> 6          data-raw         data-raw     0                 dir
#> 7       DESCRIPTION      DESCRIPTION  1668                file
#> 8              docs             docs     0                 dir
#> 9              inst             inst     0                 dir
#> 10          LICENSE          LICENSE    48                file
#> 11       LICENSE.md       LICENSE.md 34303           md   text
#> 12              man              man     0                 dir
#> 13        NAMESPACE        NAMESPACE  1909                file
#> 14          NEWS.md          NEWS.md  8847           md   text
#> 15 papercheck.Rproj papercheck.Rproj   462        rproj config
#> 16          pkgdown          pkgdown     0                 dir
#> 17          profile          profile     0                 dir
#> 18                R                R     0                 dir
#> 19        README.md        README.md   722           md   text
#> 20            tests            tests     0                 dir
#> 21        vignettes        vignettes     0                 dir
github_files("scienceverse/papercheck", dir = ".github")
#>         name               path size       ext   type
#> 1 .gitignore .github/.gitignore    7 gitignore config
#> 2  workflows  .github/workflows    0              dir

You can also retrieve files recursively. Searching a large repository recursively can take a few seconds.

github_files("scienceverse/papercheck",
             dir = ".github",
             recursive = TRUE)
#>                 name                                 path size       ext   type
#> 1         .gitignore                   .github/.gitignore    7 gitignore config
#> 2          workflows                    .github/workflows    0              dir
#> 3       pkgdown.yaml       .github/workflows/pkgdown.yaml 1316      yaml config
#> 4 test-coverage.yaml .github/workflows/test-coverage.yaml 1811      yaml config

github_info

Get all of the information about a repository in one list object, with items named “repo”, “readme”, “languages”, and “files”.

info <- github_info("scienceverse/papercheck", 
                    recursive = TRUE)

info$files |> dplyr::count(type)
#>         type    n
#> 1      audio    9
#> 2       code 1535
#> 3  code;data    4
#> 4     config   10
#> 5       data   15
#> 6        dir  130
#> 7       file   19
#> 8       font  156
#> 9      image   33
#> 10      text   32
#> 11       web  237