Skip to contents
library(papercheck)
#> 
#> 
#> *******************************************
#> ✅ Welcome to PaperCheck
#> For support and examples visit:
#> https://scienceverse.github.io/papercheck/
#> 
#> ⚠️ Set an email to use APIs like OpenAlex
#> papercheck::email('your@address.org')
#> 
#> ‼️ 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")
#> ```
#> 
#> ## API (optional)
#> To run papercheck as a REST API either using plumber or Docker, see [`inst/plumber/README.md`](inst/plumber/README.md) for instructions and documentation.

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 4360393
#> 2           R 2905592
#> 3         TeX   25601
#> 4        AMPL    7578
#> 5      Python    6986
#> 6         CSS    3358
#> 7  JavaScript    1018
#> 8  Dockerfile     933
#> 9        SCSS      19
#> 10      Shell      17

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   387    gitignore config
#> 4     .Rbuildignore    .Rbuildignore   247 rbuildignore   file
#> 5       codecov.yml      codecov.yml   134          yml config
#> 6              data             data     0                 dir
#> 7          data-raw         data-raw     0                 dir
#> 8       DESCRIPTION      DESCRIPTION  1871                file
#> 9              docs             docs     0                 dir
#> 10             inst             inst     0                 dir
#> 11       LICENSE.md       LICENSE.md 34303           md   text
#> 12              man              man     0                 dir
#> 13        NAMESPACE        NAMESPACE  1978                file
#> 14          NEWS.md          NEWS.md 12115           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   896           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 while.

github_files("scienceverse/papercheck",
             dir = ".github",
             recursive = TRUE)
#>                  name                                  path size       ext
#> 1          .gitignore                    .github/.gitignore    7 gitignore
#> 2           workflows                     .github/workflows    0          
#> 3        pkgdown.yaml        .github/workflows/pkgdown.yaml 1380      yaml
#> 4    teams-notify.yml    .github/workflows/teams-notify.yml  521       yml
#> 5  test-coverage.yaml  .github/workflows/test-coverage.yaml 1877      yaml
#> 6 upload_packages.yml .github/workflows/upload_packages.yml 3240       yml
#>     type
#> 1 config
#> 2    dir
#> 3 config
#> 4 config
#> 5 config
#> 6 config

github_info

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

github_info("scienceverse/demo")
#> $repo
#> [1] "scienceverse/demo"
#> 
#> $readme
#> [1] "# demo\nFor use in testing functions\n"
#> 
#> $files
#>        name      path size ext type
#> 1    folder    folder    0      dir
#> 2 README.md README.md   36  md text
#> 
#> $languages
#> [1] language
#> <0 rows> (or 0-length row.names)