R在哪里存储包? [英] Where does R store packages?
问题描述
R 中的 install.packages()
函数是在 R 中获取和安装包的自动解压缩实用程序.
The install.packages()
function in R is the automatic unzipping utility that gets and install packages in R.
我如何知道 R 选择了哪个目录来存储包?
How do I find out what directory R has chosen to store packages?
如何更改 R 存储和访问包的目录?
How can I change the directory in which R stores and accesses packages?
推荐答案
install.packages 命令查看 .libPaths 变量.这是我在 OSX 上的默认设置:
The install.packages command looks through the .libPaths variable. Here's what mine defaults to on OSX:
> .libPaths()
[1] "/Library/Frameworks/R.framework/Resources/library"
默认情况下我不在那里安装软件包,我更喜欢将它们安装在我的主目录中.在我的 .Rprofile 中,我有这一行:
I don't install packages there by default, I prefer to have them installed in my home directory. In my .Rprofile, I have this line:
.libPaths( "/Users/tex/lib/R" )
这会将目录/Users/tex/lib/R"添加到 .libPaths 变量的前面.
This adds the directory "/Users/tex/lib/R" to the front of the .libPaths variable.
这篇关于R在哪里存储包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!