简体   繁体   English

安装R创建两个库路径

[英]installation of R creates two library paths

I have observed that R installation in Windows creates two library paths automatically. 我观察到Windows中的R安装会自动创建两个库路径。

.libPaths()
#  [1] "C:/Users/User/Documents/R/win-library/3.4" 
#  [2] "C:/Program Files/R/R-3.4.0/library"

What is the use of these while installing new packages and which library is used? 在安装新软件包时这些有什么用?使用了哪个库? I have frequently observed the installed packages being missed and need to install again. 我经常观察到丢失的已安装软件包,需要再次安装。 How do you maintain these two paths and manage the libraries while using R or RStudio in Windows? 在Windows中使用RRStudio ,如何维护这两个路径并管理库?

Installing into C:/Program Files/R/... makes a package available to all users of the computer. 安装到C:/Program Files/R/...使软件包对计算机的所有用户可用。 It is the R default, but installing a package there from within R (using install.packages() requires that R is started with administrator privileges. 它是R的默认设置,但是从R中安装软件包(使用install.packages()要求R以管理员权限启动。

Installing into C:/Users/Username/... makes the package available to the present user only, but does not require administrative rights. 安装到C:/Users/Username/...可使程序包仅对当前用户可用,但不需要管理权限。

R tracks these paths automatically, and looks in both directories when it is asked to load a package with require() or library() . R自动跟踪这些路径,并在要求使用require()library()加载程序包时在两个目录中查找。 No user input should be required. 无需用户输入。

When you update R, the version number will of course change, meaning that R will no longer look in the folders whose paths contained the previous version number. 当您更新R时,版本号当然会更改,这意味着R将不再在其路径包含先前版本号的文件夹中查找。 Some R updaters (eg installR ) offer to copy packages from the "old" paths to the "new" paths, though an manually re-installing packages means that you can be sure that you are using the latest version of each package, and that you don't waste disk space and update time on packages that you are no longer using. 一些R更新程序(例如installR )提供将软件包从“旧”路径复制到“新”路径的方法,尽管手动重新安装软件包意味着您可以确保使用的是每个软件包的最新版本,并且您不会浪费磁盘空间,也不会在不再使用的软件包上更新时间。

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

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