找到“.Rprofile"文件生成默认选项 [英] Locate the ".Rprofile" file generating default options

查看:39
本文介绍了找到“.Rprofile"文件生成默认选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 R 和 RStudio 中,我想我已经把 .Rprofile 文件弄乱了几次,我目前正在 R 或 RStudio 启动时加载它的旧版本,有吗?一种可以快速找到生成默认选项的文件位置的方法?

In R and RStudio, I think I have messed around with the .Rprofile file a few times, and I currently am loading up an old version of it upon startup of R or RStudio, is there a way that I can quickly find the location of the file that is generating the default options?

谢谢

推荐答案

就像@Gsee 建议的那样,?Startup 有你需要的一切.请注意,不仅有用户配置文件,还有您可能弄乱的站点配置文件.而且这两个文件都可以在多个位置找到.

Like @Gsee suggested, ?Startup has all you need. Note that there isn't just the user profile file, but also a site profile file you could have messed with. And that both files can be found in multiple locations.

您可以运行以下命令以在页面上列出的文件中列出系统上的现有文件:

You could run the following to list existing files on your system among those listed on the page:

candidates <- c( Sys.getenv("R_PROFILE"),
                 file.path(Sys.getenv("R_HOME"), "etc", "Rprofile.site"),
                 Sys.getenv("R_PROFILE_USER"),
                 file.path(getwd(), ".Rprofile") )

Filter(file.exists, candidates)

请注意,它应该在刚启动 R 之后的新会话上运行,以便 getwd() 将在启动时返回当前目录.还有一个棘手的可能性是您的配置文件在启动时确实修改了当前目录,在这种情况下,您必须启动无配置文件"会话(运行 R --no-site-file --no-init-file) 在运行上面的代码之前.

Note that it should be run on a fresh session, right after your started R, so that getwd() will return the current directory at startup. There is also the tricky possibility that your profile files do modify the current directory at startup, in which case you would have to start a "no-profile" session (run R --no-site-file --no-init-file) before running the code above.

这篇关于找到“.Rprofile"文件生成默认选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆