我在 MAC 中的 R 上输入了一些代码,在关闭 R 之前,它询问“保存工作区图像?” 我点击“保存”,认为它会保存我的代码。但我找不到我的代码在哪里?那么 MAC 的 R 默认路径在哪里,如何找到我的代码?
提前致谢
If you just executed save.image()
and then hit yes, your data was saved to a file called .Rdata
In terminal, type ls -alh
in the same working directory and you'll see it.
If you're not sure what dir you're in, in R type getwd()
save.image
不会在.Rdata
文件中保存创建数据对象的命令。相反,您需要查看在.Rhistory
会话结束时自动保存的文件。默认路径是工作目录。如果您使用的是 R.app 或 R64.app GUI 工作环境,则文件的名称为“.Rapp.history”,但如果是终端会话,则命名为“.history”。在 R 会话中,您可以通过键入来获取最后 25 行history()
。如果您在该history
调用中放置一个数字参数,则可以更改显示的行数。
?history
?getwd
另请查看 R Mac 常见问题解答。它描述了 R.app GUI 与您在?loadhistory
. 您可能还需要学习如何查看“点文件”或“系统文件”。长期以来,通过打开终端并在命令行中键入以下内容就可以实现这一点:
machine-name:dir username$ defaults write com.apple.finder AppleShowAllFiles YES:
重新启动或重新启动 Finder。我将 .Rhistory(从 R 的终端启动中保存的文件)和 .Rhistory.history(从 R-GUI 启动的会话中保存的文件)保存在我的用户文件夹的“根”中。