Man Linux: Main Page and Category List

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

       Equivalently, R commands can be given on the command-line:

        r -e ’cat(pi^2, "\n")’

       Alternatively,  commands  can  be stored in a file, which in turn might
       use R command ’readLines’ to process stdin input:

        $ cat examples/fsizes.r
        fsizes <- as.integer(readLines())
        print(summary(fsizes))
        stem(fsizes)

       which can be evaluated by r with the following command:

        ls -l /boot | awk ’!/^total/ {print $5}’ | r examples/fsizes.r

       The script file may contain a "shebang" line:

        $ 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)

       and if it is executable, it can be called as:

        examples/install.r "TeachingDemos"

       See the examples directory in the sources for more.

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>.