R(1) | User Commands | R(1) |
NAME¶
r - Provides hash-bang (#!) capability for R (www.r-project.org)SYNOPSIS¶
r [ options] [-|file] [R arguments]DESCRIPTION¶
Launches GNU R to execute the specified file containing R commands, or takes commands from stdin if '-' is used to denote stdin, using the specified options. This makes it suitable to create R scripts via the so-called shebang '#!/' line. The optional R arguments are stored in the R vector argv.OPTIONS¶
- -h, --help
- Display a short help list.
- --usage
- Give a short usage message.
- -V, --version
- Show the version number.
- -v, --vanilla
- Pass the '--vanilla' option to R.
- -p, --verbose
- Print the value of expressions to the console.
- -l, --packages list
- Load the R packages from the comma-separated 'list'.
- -t, --rtemp
- Use a per-session temporary directory as R does.
- -q, --quick
- Skip autoload (i.e. delayed assign) of default libraries.
- -i, --interactive
- Force 'interactive()' to evaluate to TRUE, whereas the default is FALSE.
- -e, --eval expr
- Evaluate 'expr' in R.
USAGE¶
r can be used in command-line 'pipes' as well as in 'shebang'-style scripts.EXAMPLES¶
Piping R commands:echo 'cat(pi^2,"\n")' | r
r -e 'cat(pi^2, "\n")'
$ cat examples/fsizes.r
fsizes <- as.integer(readLines())
print(summary(fsizes))
stem(fsizes)
ls -l /boot | awk '!/^total/ {print $5}' | r examples/fsizes.r
$ cat examples/install.r
#!/usr/bin/env r
# a simple example to install one or more packages
if (is.null(argv) | length(argv)<1) {
cat("Usage: installr.r pkg1 [pkg2 pkg3 ...]0)
q()
}
repos <- "http://cran.us.r-project.org"
lib.loc <- "/usr/local/lib/R/site-library"
install.packages(argv, lib.loc, repos, dependencies=TRUE)
examples/install.r "TeachingDemos"
NOTE¶
The executable program is called r, but the project is called littler to avoid confusion with the real GNU R.SEE ALSO¶
The GNU R language is documented extensively at the R website (http://www.r-project.org) and in several manuals available in html, info and pdf.AUTHORS¶
Jeffrey Horner <jeff.horner@vanderbilt.edu>. Dirk Eddelbuettel <edd@debian.org>.September 2006 | r |