gpt4 book ai didi

从命令行运行 R 命令

转载 作者:行者123 更新时间:2023-12-04 10:14:33 30 4
gpt4 key购买 nike

有没有办法从命令行运行 R 命令?就像是

$ R --run '1+1'
2

甚至喜欢
$ Rscript < '1+1'
2

最佳答案

命令行选项 -e正是这样做的。

Rscript.exe -e "1+1"

[1] 2

如果你只是运行 RScript,你得到的帮助中已经清楚地说明了这一点。不带参数:
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

关于从命令行运行 R 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45809083/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com