r - 在 Windows 命令行上执行的 Rscript 不显示任何结果
问题描述
我正在尝试在 windows cmd 上运行非常简单的 Rscript 文件。
我要测试的 Rscript 如下:
setwd("C:\Users\Lily\Tutorial0")
Product <-function(a,b)
{
p <- a*b
return(p)
}
result <- Product(10,0.4);
print("Calculating the result...")
print(result);
为了使用命令Rscript
,我在 PATH 变量中添加了 Rscript.exe 和 R.exe 的路径,因为我在 D 驱动器上安装了 R。
然而,Rscript 命令似乎工作,但我想要的结果(即“计算结果....4)没有出来。实际上除了下一行输入之外什么也没出现。
C:\Users\Lily>Rscript Tutorial0.R
C:\Users\Lily>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 --no-echo --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
如何在窗口 cmd 上显示结果?
解决方案
推荐阅读
- c# - 日期字段未填充在 Razor 页面中
- git - WebStorm 的默认变更列表需要很长时间才能更新
- python - Python最有效的数据结构来保存值并检查值是否存在
- flutter - 无法构建 AAR,找不到任务“assembleAarDebug”
- php - 如何延迟测试 Laravel 作业?
- reinforcement-learning - 具有稳定基线的自定义 Openai 健身房环境
- flutter - 在 ListView.builder 中显示信息时出现问题
- python-3.x - 在列表 [data] = self.read() 中声明一个 python 变量?
- php - WP_User_Query 用户前查询 DISTINCT 重复结果
- python - Selenium Python:选择一个类中的所有项目并将它们放入列表中?