2017-08-22 5 views

答えて

2

のようなコマンドラインオプション-eは、まさにそのような何か。

Rscript.exe -e "1+1" 

[1] 2 

あなただけのパラメータなしでRScriptを実行する場合、それは明らかにあなたが得る助けに説明されている:man Rから

$ R --slave -e '1+1' 
[1] 2 

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

--options accepted are 
    --help    Print usage and exit 
    --version   Print version and exit 
    --verbose   Print information on progress 
    --default-packages=list 
         Where 'list' is a comma-separated set 
         of package names, or 'NULL' 
or options to R, in addition to --slave --no-restore, such as 
    --save    Do save workspace at the end of the session 
    --no-environ  Don't read the site and user environment files 
    --no-site-file  Don't read the site-wide Rprofile 
    --no-init-file  Don't read the user R profile 
    --restore   Do restore previously saved objects at startup 
    --vanilla   Combine --no-save, --no-restore, --no-site-file 
         --no-init-file and --no-environ 

'file' may contain spaces but not shell metacharacters 
Expressions (one or more '-e <expr>') may be used *instead* of 'file' 
See also ?Rscript from within R 
0

あなたがRコマンドでそれを行うことができます:

--slave 
      Make R run as quietly as possible 

    -e EXPR 
      Execute 'EXPR' and exit 
0

がインストールされ、rのパスが適切にあなたがこのような何かを行うことができ、設定さ:

echo 'print(1+1)' | r 
# [1] 2 

注意、rはタイプミスではありません。 littlerからのコマンドです。あなたが式の中で明示的にprint/cat/...を呼び出すときにのみ印刷しているようです

r -e 'print(1+1)'  
# [1] 2 

:それはまたRRscriptなどの-eオプションをサポートしています。

関連する問題