这是R 3.5中的错误吗?

时间:2022-06-29 17:00:35

When I call Rscript.exe for Version 3.5 of R, it is unable to open the file if the file name or path has a space in it. I saved 2 files with the code:

当我为R版本3.5调用Rscript.exe时,如果文件名或路径中有空格,则无法打开该文件。我用代码保存了2个文件:

cat("What do you get when you multiply 6 * 9?")

猫(“当你乘以6 * 9时你会得到什么?”)

as C:\foo bar.R and as C:\foo_bar.R

如C:\ foo bar.R和C:\ foo_bar.R

When I in a DOS command window try to run these using version 3.4.3 and 3.5:

当我在DOS命令窗口中尝试使用版本3.4.3和3.5运行它们时:

C:\>"C:\Program Files\R\R-3.4.3\bin\x64\Rscript.exe" "C:\foo bar.R"
What do you get when you multiply 6 * 9?
C:\>"C:\Program Files\R\R-3.4.3\bin\x64\Rscript.exe" "C:\foo_bar.R"
What do you get when you multiply 6 * 9?
C:\>"C:\Program Files\R\R-3.5.0\bin\x64\Rscript.exe" "C:\foo bar.R"
Fatal error: cannot open file 'C:\foo': No such file or directory


C:\>"C:\Program Files\R\R-3.5.0\bin\x64\Rscript.exe" "C:\foo_bar.R"
What do you get when you multiply 6 * 9?
C:\>

When I try to run the file with a space in the name in version 3.5.0 of R, there is a fatal error saying there is no such file.

当我尝试在R版本3.5.0中使用名称中的空格运行文件时,会出现致命错误,表示没有此类文件。

1 个解决方案

#1


4  

Thanks Edward Carney, I emailed the address you listed, and got a response from Tomas confirming it is a bug, and providing a workaround until it is fixed:

感谢Edward Carney,我通过电子邮件发送了您列出的地址,并收到了Tomas的回复,确认这是一个错误,并提供解决方法,直到修复为止:

A quick workaround before this gets fixed is to add an extra first argument that has no space in it, e.g.

在此问题得到修复之前的快速解决方法是添加一个没有空格的额外第一个参数,例如:

Rscript --vanilla "foo bar.R"

The problem exists on all systems, not just Windows.

所有系统都存在问题,而不仅仅是Windows。

This has now been corrected in the Development version, and there is a binary build for Windows at: https://cran.r-project.org/bin/windows/base/rdevel.html

现在已经在开发版本中对此进行了更正,并且有一个适用于Windows的二进制版本:https://cran.r-project.org/bin/windows/base/rdevel.html

It has also been corrected in the patched version, and there is a binary build for Windows at: https://cran.r-project.org/bin/windows/base/rpatched.html

它在修补版本中也得到了纠正,并且有一个适用于Windows的二进制版本:https://cran.r-project.org/bin/windows/base/rpatched.html

#1


4  

Thanks Edward Carney, I emailed the address you listed, and got a response from Tomas confirming it is a bug, and providing a workaround until it is fixed:

感谢Edward Carney,我通过电子邮件发送了您列出的地址,并收到了Tomas的回复,确认这是一个错误,并提供解决方法,直到修复为止:

A quick workaround before this gets fixed is to add an extra first argument that has no space in it, e.g.

在此问题得到修复之前的快速解决方法是添加一个没有空格的额外第一个参数,例如:

Rscript --vanilla "foo bar.R"

The problem exists on all systems, not just Windows.

所有系统都存在问题,而不仅仅是Windows。

This has now been corrected in the Development version, and there is a binary build for Windows at: https://cran.r-project.org/bin/windows/base/rdevel.html

现在已经在开发版本中对此进行了更正,并且有一个适用于Windows的二进制版本:https://cran.r-project.org/bin/windows/base/rdevel.html

It has also been corrected in the patched version, and there is a binary build for Windows at: https://cran.r-project.org/bin/windows/base/rpatched.html

它在修补版本中也得到了纠正,并且有一个适用于Windows的二进制版本:https://cran.r-project.org/bin/windows/base/rpatched.html