R.from.shell {this.path}R Documentation

Using R From a Shell

Description

How to use R from a shell (including the Windows command-line / / Unix terminal).

Details

For the purpose of running R scripts, there are four ways to do it. Suppose our R script has filename script1.R, we could write any of:

The first two are different ways of writing equivalent statements. The third statement is the first statement plus options --restore --save (plus option --no-readline under Unix-alikes), and it also saves the stdout and stderr in a file of your choosing. The fourth statement is the second statement plus options --no-echo --no-restore. You can try:

for a help message that describes what these options mean. In general, Rscript is the one you want to use. It should be noted that Rscript has some exclusive environment variables (not used by the other executables) that will make its behaviour different from R.

For the purpose of making packages, R CMD is what you will need. Most commonly, you will use:

R CMD build will turn an R package (specified by a directory) into tarball. This allows for easy sharing of R packages with other people, including submitting a package to CRAN. R CMD INSTALL will install an R package (specified by a directory or tarball), and is used by install.packages(). R CMD check will check an R package (specified by a tarball) for possible errors in code, documentation, tests, and much more.

Where are my R executable files located?

In an R session, you can find the location of your R executable files with the following command:

R.home("bin")

For me, this is:

⁠/usr/lib/R/bin⁠


[Package this.path version 2.6.0 Index]