GitHub repositories often carry tagged R package releases and development builds before the same code reaches CRAN. Naming a tag during installation keeps the selected source from moving when the repository's default branch changes.

The pak package manager accepts the shorthand owner/repository@reference for a GitHub package. The reference may identify a tag, branch, or commit; the public r-lib/prettyunits@v1.2.0 tag provides a repeatable installation without requiring the reader to supply a credential.

The installed package metadata records the repository owner, requested tag, and resolved commit SHA. Loading the namespace and calling one exported function proves that R can use the package, while the metadata distinguishes this build from a package with the same version installed from another source.

Steps to install an R package from GitHub:

  1. Install the prettyunits v1.2.0 GitHub tag with pak.
    > pak::pkg_install("r-lib/prettyunits@v1.2.0")
     
    > Package library at '/usr/local/lib/R/site-library'.
    > Will install 1 package.
    + prettyunits   1.2.0 [bld][cmp][dl] (GitHub: 8305a9a)
    ##### snipped #####
    v Installed prettyunits 1.2.0 (github::r-lib/prettyunits@8305a9a) (28ms)
    v 1 pkg: added 1, dld 1 (NA B) [4.3s]
    >

    A token written inside the repository reference or R command can be exposed through saved history. Private-repository credentials should be supplied through pak's Git credential integration outside the package reference.

  2. Load the installed prettyunits namespace.
    > library(prettyunits)
    >
  3. Exercise the installed package with pretty_bytes().
    > prettyunits::pretty_bytes(1024)
    [1] "1.02 kB"
    >
  4. Confirm the installed prettyunits version.
    > packageVersion("prettyunits")
    [1] '1.2.0'
    >
  5. Verify the installed GitHub source against the requested repository tag.
    > packageDescription("prettyunits")[c("Package", "Version", "RemoteUsername", "RemoteRepo", "RemoteRef", "RemoteSha")]
    $Package
    [1] "prettyunits"
    
    $Version
    [1] "1.2.0"
    
    $RemoteUsername
    [1] "r-lib"
    
    $RemoteRepo
    [1] "prettyunits"
    
    $RemoteRef
    [1] "v1.2.0"
    
    $RemoteSha
    [1] "8305a9a97d65bbbd6eb5902076bc2f3a701c43e9"
    
    >