R .Library 和 libpaths() returns 不同的结果

R .Library and libpaths() returns different result

libpaths() returns 有效结果:

"D:/R/R-3.3.3/library"

但是 .Library returns 结果无效:

"D:/R/R-33~1.3/library"

这是否符合预期?

使用 Mac 我也得到了两条不同的路径:

.Library
# [1] "/Library/Frameworks/R.framework/Resources/library"

.libPaths()
# [1] "/Library/Frameworks/R.framework/Versions/3.6/Resources/library"

文档对 .Library 有这样的说法(强调我的):

.Library is a character string giving the location of the default library, the ‘library’ subdirectory of R_HOME.

关于 .libPaths()(强调我的):

.libPaths is used for getting or setting the library trees that R knows about (and hence uses when looking for packages).

实际上,两个路径通过不同的路由指向同一个目录,因为第一个路径中的Resources是指向第二个路径中相同Resources的别名。主要区别在于第二个路径中的 Versions 包含针对不同版本的多个目录(即所谓的 "library trees that R knows about")。 3.6 版目前是我的默认库,这就是 .Library 也指向它的原因。我假设相同的逻辑适用于 Windows.

它们应该是一样的

但是在 windows 中,您不能直接使用 .Library 的值来定位文件夹。

但是当我使用 libpaths 和 .Library 创建文件夹时,结果位于同一文件夹中~

因为我认为这很有用,所以我 post 在这里回答我自己的问题。