Usage: /path/to/Rscript [--options] [-e expr] file [args]

利用例: より抜粋


バッチ実行には、Rscript.exe を使うこともできます。

Rscript [--options] [-e expr] inputfile [args]

Rscript には出力ファイルを指定するオプションがありませんが、出力のリダイレクトで代用できます。
Windows 版の Rcmd BATCH ではスクリプトへ引数を渡す機能がうまく使えませんが、Rscript ではちゃんと引数を渡すことができます。
Rscript は直接に表現式を書ける -e オプションが利用でき(このオプションは Rterm の機能)、かなり便利です。

Rscript -e "commandArgs(); proc.time()" arg1 arg2 arg3


Rscript [--options] [-e expr] inputfile [args] > outputfile




R(1)                                  FSF                                 R(1)

       R - a language for data analysis and graphics

       R [options] [< infile] [> outfile]
       R CMD command [arguments]

       Start  R,  a  system for statistical computation and graphics, with the
       specified options, or invoke an R tool via the 'R CMD' interface.

       R is a language which bears a passing resemblance  to  the  S  language
       developed at AT&T Bell Laboratories.  It provides support for a variety
       of statistical and graphical analyses.  R is a true  computer  language
       which contains a number of control-flow constructions for iteration and
       alternation.  It allows users to add additional functionality by defin-
       ing new functions.

       On  platforms which support the dlopen(3) interface, Fortran and C code
       can be linked and called at run time.

       On systems which have the GNU readline(3) library, R  will  maintain  a
       command  history,  so that commands can be recalled, edited and re-exe-

       Most options control what happens at the beginning and at the end of an
       R  session,  in  particular which files are being read and written, and
       how much memory is reserved for the R process.

       -h, --help
              Print short help message and exit

              Print version info and exit

       RHOME  Print path to R home directory and exit

       --save Do save data sets at the end of the session

              Don't save them

              Don't read the site and user environment files

              Don't read the site-wide Rprofile

              Don't read the .Rprofile or ~/.Rprofile files

              Do restore previously saved data sets at startup

              Don't restore previously saved data sets

              Don't restore the R history file

              Don't restore anything

              Combine --no-save, --no-restore, --no-site-file,  --no-init-file
              and --no-environ

              Don't use readline for command-line editing

              Set vector heap min to N bytes; '4M' = 4 MegaB

              Set vector heap max to N bytes;

              Set min number of cons cells to N

              Set max number of cons cells to N

       -q, --quiet
              Don't print startup message

              Same as --quiet

              Make R run as quietly as possible

              Print more information about progress

       -d, --debugger=NAME
              Run R through debugger NAME

              Pass ARGS as arguments to the debugger

       -g, --gui=TYPE
              Use TYPE as GUI; possible values are 'X11' (default), 'none' and

       --args Skip the rest of the command line

       BATCH  Run R in batch mode

              Compile files for use with R

       SHLIB  Build shared library for dynamic loading

              Install add-on packages

       REMOVE Remove add-on packages

       build  Build add-on packages

       check  Check add-on packages

       LINK   Front-end for creating executable programs

       Rprof  Post-process R profiling files

       Rdconv Convert Rd format to various other formats

       Rd2dvi Convert Rd format to DVI/PDF

       Rd2txt Convert Rd format to pretty text

       Sd2Rd  Convert S documentation to Rd format

       config Obtain configuration information about R

       The first five tools (i.e., BATCH, COMPILE, SHLIB, INSTALL, and REMOVE)
       can also be invoked without the 'CMD' option.

       Please  use  'R CMD command --help' to obtain further information about
       the usage of 'command'.

       Report bugs to <>.

       Copyright (C) 2003 R Development Core Team

       R is free software and comes with ABSOLUTELY NO WARRANTY.  You are wel-
       come  to  redistribute  it  under  the  terms of the GNU General Public
       License.    For   more   information   about   these    matters,    see

       The  full  documentation  for  R is provided by a collection of Texinfo
       manuals and individual help for R objects which is also  available  on-

       Start  R  and type ?topic at the R prompt to obtain on-line information
       for `topic'.

       If the processed manuals have been installed they will be available  as
       DVI and/or PDF files in the directory `R RHOME`/doc/manual.

       If  the  info  program  and the R manuals are installed on your system,
       typing info -f R-intro, info -f R-data, info -f  R-exts,info  -f  R-FAQ
       and  info  -f R-lang should give you access to ``An Introduction to R''
       (the basic manual), the ``R Data Import/Export'' Guide, the ``R  Exten-
       sion  Writer's  Guide'', the ``R FAQ'' and the ``The R Language Defini-

R 1.8.1                          November 2003                            R(1)

$ cat r.R

$ R --vanilla --silent < r.R > r.output
$ cat r.output
> summary(iris)
  Sepal.Length    Sepal.Width     Petal.Length    Petal.Width   
 Min.   :4.300   Min.   :2.000   Min.   :1.000   Min.   :0.100  
 1st Qu.:5.100   1st Qu.:2.800   1st Qu.:1.600   1st Qu.:0.300  
 Median :5.800   Median :3.000   Median :4.350   Median :1.300  
 Mean   :5.843   Mean   :3.057   Mean   :3.758   Mean   :1.199  
 3rd Qu.:6.400   3rd Qu.:3.300   3rd Qu.:5.100   3rd Qu.:1.800  
 Max.   :7.900   Max.   :4.400   Max.   :6.900   Max.   :2.500  
 setosa    :50  
 virginica :50


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2015-03-01 (日) 01:15:59