您会在 R 会话之前/之后放置什么代码?
R 允许我们将代码放在会话的开始/结束时运行。
您建议在那里放置哪些代码?
我知道三个有趣的例子(尽管我不知道“如何做”):
- 关闭 R 时保存会话历史记录
- 。在 R 会话开始时运行 Fortune()。
- 我正在考虑自动保存工作空间。但我并没有着手解决管理空间的问题(因此总会有 X 空间用于该备份)
还有更多想法吗? (或者如何实现上述想法)
ps:这是继续在 “stat.overflow”
R allows us to put code to run in the beginning/end of a session.
What codes would you suggest putting there?
I know of three interesting examples (although I don't have "how to do them" under my fingers here):
- Saving the session history when closing R.
- Running a fortune() at the beginning of an R session.
- I was thinking of having an automated saving of the workspace. But I didn't set on solving the issue of managing space (so there would always be X amount of space used for that backup)
Any more ideas? (or how you implement the above ideas)
p.s: this is continuing a thread started on "stat.overflow"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除了 .Rprofile 之外,您还可以定义
.First
和.Last
函数。我通常使用graphics.off()
来摆脱任何正在运行的图形显示,因此,在这种情况下,它应该是这样的:并得到这样的结果:
然而,这并不多有用。虽然 .Rprofile 管理 R 启动,.Last 函数可以“退出时”执行各种操作...例如保存图像文件等...
Apart from .Rprofile, you could define
.First
and.Last
functions. I usually putgraphics.off()
to get rid of any graphic displays running, so, in this case, it should go something like this:and get something like this:
However, this ain't much useful. While .Rprofile manages R start-up, .Last function can perform various operations "on exit"... like saving image file or so...
我很确定我们之前也有过这样的问题。请参阅专家 R 用户,您的 .Rprofile 中有什么? 或更多内容一般搜索“[r[启动”或其他适当的标签。
I am pretty sure we had a question like this here before. See eg Expert R users, what's in your .Rprofile? or more generally search for "[r[ Startup" or other appropriate tags.