rt: R Tools for the Command Line
This package ships some command line utilities which simplify working with R packages from the command line. Many commands rt provides are just wrappers around devtools but ensure a valid exit code which is required to use these commands for shell scripting. Furthermore, rt allows you to maintain a collection of you favorite packages in a plain text file which you can add to your dotfiles and share across systems. This file may also contain git sources to keep you up to date with packages not yet released on CRAN.
rbuildto bundle a local package.
rcheckto check a local package.
.[o|so]files from a local package.
rcloneto clone a GitHub package to your system
rcompileto compile Sweave (.Rnw) and Rmarkdown (.Rmd) files to HTML or PDF.
rcovto test the coverage of a local package.
rdocto document a local package using roxygen.
rhubto upload a local package to rhub service.
rinstallto install a remote package, e.g. a package hosted on CRAN or GitHub.
rknitto knit a knitr document (.Rnw, .Rrst) to PDF.
rmaketo make a local package (document and install).
rmarkdownto render a Rmarkdown (.Rmd) file.
rpkgdownto build static HTML documentation with pkgdown.
rreleaseto release a local package to CRAN.
rremoveto remove (uninstall) R packages.
rshineto run a shiny app.
rspellto check spelling in generated .Rd files.
rtestto test a local package.
rtstchkto test and check a local package.
rupdateto update all CRAN packages on your system, install missing CRAN packages listed in your collection
~/.rt/packagesand update all packages with a git source.
rusageto check variable usage.
rvignetteto build vignettes.
rwinbuildto upload a local package to the winbuilder service.
Call the respective command with
--help to list available command line arguments.
All commands are also available as regular R functions, using the same names.
First, you need to install rt itself.
Using a personal library (e.g.,
echo 'R_LIBS_USER=~/.R/library' >> ~/.Renviron) is strongly advised.
Alternatively, if you start from scratch and do not have devtools installed, run the following command in your shell:
Rscript -e 'install.packages("devtools", repos = "http://cloud.r-project.org/")' Rscript -e 'devtools::install_github("rdatsci/rt")'
The rt command line scripts are now installed in the subdirectory
rt/bin of your R library (call
.libPaths() in R if
unsure about its location). You need to add this directory to your
PATH variable, see the section below that applies to you.
Add this directory to your
PATH in your
# bash PATH=~/.R/library/rt/bin:$PATH # zsh path=(~/.R/library/rt/bin $path) # fish if test -d ~/.R/library/rt set -gx PATH $HOME/.R/library/rt/bin $PATH end
Add this directory to your
PATH variable in the system environment via the control panel.
As an alternative use the admin console command:
SETX /M PATH "%PATH%;path-to-rt-repository/win"
/M changes the
HKEY_LOCAL_MACHINE instead of
If it does not work for you, try it without the
In any case you need to open a new windows prompt or terminal windows in order to reload the
Continue for both Systems
After sourcing this file (or after a re-login) you should be all set to use rt.
To keep rt updated, you can let it maintain itself via
rupdate by adding it to your collection file
To do this, first initialize an empty collection with
and then uncomment the respective line with your favorite text editor.
To add more packages to your collection, see
?rupdate for a format description of this file.
Note that packages with a git source will be kept in
~/.rt/git and only reinstalled if the remote repository has been updated.