如何更改 R 包的默认库路径 [英] How do I change the default library path for R packages

查看:130
本文介绍了如何更改 R 包的默认库路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我的工作计算机的本地驱动器上安装 R 和 R studio,而不是组织网络文件夹,因为通过网络运行的任何东西都非常慢.安装时,目标路径显示它是我的本地 C: 驱动器.但是,当我安装新软件包时,显示的默认路径是我的网络驱动器,并且没有更改选项:

I have attempted to install R and R studio on the local drive on my work computer as opposed to the organization network folder because anything that runs through the network is really slow. When installing, the destination path shows that it's my local C:drive. However, when I install a new package, the default path shown is my network drive and there is no option to change:

.libPaths()
[1] "\\\\The library/path/I/don't/want"
[2] "C:/Program Files/R/R-3.2.1/library" 

我正在运行 Windows 7 专业版.如何删除库路径 [1] 并使路径 [2] 成为我安装的所有基本软件包和所有新软件包的主要路径?

I'm running windows 7 professional. How can I remove library path [1] and make path [2] my primary for all base packages and all new packages that I install?

推荐答案

请参阅 help(Startup)help(.libPaths) 因为您有几种可能已经设置.其中

See help(Startup) and help(.libPaths) as you have several possibilities where this may have gotten set. Among them are

  • 设置R_LIBS_USER
  • .RprofileRprofile.site
  • 中分配 .libPaths()

还有更多.

在这种特殊情况下,您需要返回并取消设置 \\\\The library/path/I/don't/want 设置的位置.

In this particular case you need to go backwards and unset whereever \\\\The library/path/I/don't/want is set.

要以其他方式忽略它,您需要明确地覆盖它,即通过

To otherwise ignore it you need to override it use explicitly i.e. via

library("somePackage", lib.loc=.libPaths()[-1])

加载包时.

这篇关于如何更改 R 包的默认库路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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