[英]Can I prevent R from creating .RData files?
I am trying to share some R code with colleagues who don't know R.我正在尝试与不知道 R 的同事分享一些 R 代码。 I have created a batch file so they can just double-click it and run the R script without even opening R.
我创建了一个批处理文件,因此他们只需双击它并运行 R 脚本,甚至无需打开 R。 But it creates a
.RData
file.但它会创建一个
.RData
文件。
My question is, can I prevent R from creating the .RData
file?我的问题是,我可以阻止 R 创建
.RData
文件吗?
I've read here Disable saving history that I could disable it through RStudio global options but my colleagues are installing just R and won't need to ever open it, so I am looking for some kind of solution of the likes of options(...)
that I can just put in my Rscript, or maybe something that could be speficied in the batch file call.我在这里阅读了禁用保存历史记录,我可以通过 RStudio 全局选项禁用它,但我的同事只安装 R 并且不需要打开它,所以我正在寻找某种解决方案,例如
options(...)
我可以只放入我的 Rscript,或者可以在批处理文件调用中指定的内容。
For anyone curious, I figured it out thanks to @r2evans and this post: https://es.stackoverflow.com/questions/166211/evitar-que-r-cree-ficheros-r-data-yr-history .对于任何好奇的人,我感谢@r2evans 和这篇文章: https://es.stackoverflow.com/questions/166211/evitar-que-r-cree-ficheros-r-data-yr-history 。
I just had to add --no-save
to my batch call like this:我只需要像这样将
--no-save
添加到我的批处理调用中:
R CMD BATCH --no-save "%file%" NUL
where %file%
is the Rscript path.其中
%file%
是 Rscript 路径。 The NUL
part is so a .Rout
file won't be created after running the batch file. NUL
部分是在运行批处理文件后不会创建.Rout
文件。
Also, doing另外,做
Rscript.exe "%file%"
runs the Rscript and doesn't produce .RData
or .Rout
files.运行 Rscript 并且不生成
.RData
或.Rout
文件。 The difference is that R messages get printed on the command window as they would in an interactive R session.不同之处在于 R 消息在命令 window 上打印,就像在交互式 R Z21D6F4740CFB51190A92E 中一样
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.