简体   繁体   English

R .libPaths()自动重置

[英]R .libPaths() automatically reset

OS: Mac OS X 10.10.3 R version: 3.2.0 (installed by Homebrew) 操作系统:Mac OS X 10.10.3 R版本:3.2.0(由Homebrew安装)

I want R to install packages in my home directory instead of the default "R_HOME", so I don't have to reinstall all packages after updating R. 我希望R将软件包安装在我的主目录中,而不是默认的“ R_HOME”,因此在更新R之后不必重新安装所有软件包。

I set the library path by .libPaths('~/Library/R/') . 我通过.libPaths('~/Library/R/')设置库路径。 After that, all packages were installed in ~/Library/R . 之后,所有软件包都安装在〜/ Library / R中 Checking by .libPaths() returned ~/Library/R and the R_HOME. 通过.libPaths()检查返回〜/ Library / R和R_HOME。

However, when I quit R (in RStudio or in terminal) and reopen R (in RStudio or terminal), .libPaths() only returned the R_HOME. 但是,当我退出R(在RStudio或终端中)并重新打开R(在RStudio或终端中)时, .libPaths()仅返回R_HOME。 I have to manually set .libPaths('~/Library/R/') again (the packages are still there). 我必须再次手动设置.libPaths('~/Library/R/') (程序包仍然存在)。

Why does the library path automatically reset and how could I change it permanently? 为什么库路径会自动重置,如何永久更改?

I did something similar. 我做了类似的事情。 Check your Sys.getenv() . 检查您的Sys.getenv() Mine has 57 items. 我的有57件。 One of them is Sys.getenv()['R_LIBS'] . 其中之一是Sys.getenv()['R_LIBS'] I set it to "/Users/ghuiber/Rlibs" and it is persistent. 我将其设置为"/Users/ghuiber/Rlibs" ,它是持久的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM