rdatsci / rtcl

R tools for the command line
65 stars 3 forks source link

rtcl: R Tools for the Command Line

Travis build status Coverage status

This package ships some command line utilities which simplify working with R packages from the command line. Many commands rtcl provides are just wrappers around , e.g. remotes and testthat. They ensure a valid exit code which is required to use these commands for shell scripting. You find additional packages via R infrastructure. Furthermore, rtcl 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.

Available Commands

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.

Setup

First, you need to install rtcl itself. Using a personal library (e.g., echo 'R_LIBS_USER=~/.R/library' >> ~/.Renviron) is strongly advised.

install.packages("remotes")
remotes::install_github("rdatsci/rtcl")

Alternatively, if you start from scratch and do not have remotes installed, run the following command in your shell:

Rscript -e 'install.packages("remotes", repos = "http://cloud.r-project.org/")'
Rscript -e 'remotes::install_github("rdatsci/rtcl")'

The rtcl command line scripts are now installed in the subdirectory rtcl/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.

On Linux

Add this directory to your PATH in your .bashrc, .zshrc or config.fish:

# bash
PATH=~/.R/library/rtcl/bin:$PATH

# zsh
path=(~/.R/library/rtcl/bin $path)

# fish
if test -d ~/.R/library/rtcl
    set -gx PATH $HOME/.R/library/rtcl/bin $PATH
end

On Windows

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-rtcl-repository/win"

(Option /M changes the PATH in HKEY_LOCAL_MACHINE instead of HKEY_CURRENT_USER). If it does not work for you, try it without the /M option. In any case you need to open a new windows prompt or terminal windows in order to reload the PATH variable.

Continue for both Systems

After sourcing this file (or after a re-login) you should be all set to use rtcl.

To keep rtcl updated, you can let it maintain itself via rupdate by adding it to your collection file ~/.config/rtcl/packages. To do this, first initialize an empty collection with

rtcl --init

and then edit the file with your favorite text editor. To add more packages to your collection, see ?rupdate for a format description of this file. You can also edit the package collection file by calling:

rtcl --packages

rwinbuild and rhub: maintainer

If you want to check packages on rhub or with the winbuilder that are not yours, you have to change the maintainer temporarily. rtcl does that for you if you configure your maintainer details in ~/.config/rtcl/config. You can edit this file with any text editor or by calling:

rtcl --config