# Installation

#### Mark Padgham

#### 2026-02-10

The `pkgstats` package is on CRAN, so can be installed directly with,

    install.packages ("pkgstats")

The latest development version can be installed via the associated `r-universe`. As shown there, simply enable the universe with

    options (repos = c (
        ropenscireviewtools = "https://ropensci-review-tools.r-universe.dev",
        CRAN = "https://cloud.r-project.org"
    ))

And then call `install.packages()` the same way. Alternatively, the development version of the package can be installed by running one of the following lines:

    remotes::install_github ("ropensci-review-tools/pkgstats")
    pak::pkg_install ("ropensci-review-tools/pkgstats")

The package can then loaded for use with:

    library (pkgstats)

## Installation on Linux systems

This package requires the system libraries `ctags-universal` and GNU `global`, both of which are automatically installed along with the package on both Windows and MacOS systems. Most Linux distributions do not include a sufficiently up-to-date version of `ctags-universal`, and so it must be compiled from source. This can be done by running a single function, `ctags_install()`, which will install both `ctags-universal` and GNU `global`.

The `pkgstats` package includes a function to ensure your local installations of `universal-ctags` and `global` work correctly. Please ensure you see the following prior to proceeding:

    ctags_test ()
    #> [1] TRUE

Note that GNU `global` can be linked at installation to the Universal Ctags plug-in parser to expand the default 5 languages to 30. This makes no difference to `pkgstats` results, as `gtags` output is only used to trace function call networks, which is only possible for compiled languages able to dynamically share pointers to the same objects. This is possible with the default parser regardless. The wealth of extra information obtained from linking `global` to the Universal Ctags parser is ultimately discarded anyway, yet parsing may take considerably longer. If this is the case, “default” behaviour may be recovered by first running the following command:

    Sys.unsetenv (c ("GTAGSCONF", "GTAGSLABEL"))

# Installation on macOS systems

On macOS, GNU `global` and `universal-ctags` can be easily installed with Homebrew. First follow the instructions at https://brew.sh/ to install Homebrew if you don’t have it already. Then run the following command in your terminal:

    brew install global

This will install both `global` and a compatible version of `universal-ctags`.

Do not install `ctags` via Homebrew with `brew install ctags` as the installed version will conflict with `global`’s required `universal-ctags` dependency. If you have `ctags` already installed for another purpose, see Homebrew’s messages in the console on how to proceed after attempting to intall `global`, it will usually involve unlinking the existing `ctags` with `brew unlink ctags` or removing it completely with `brew rm ctags`.