如何在Mac OSX中查找R库的位置?

26
在 Linux 上通常是 $HOME/R/...,那么在 Mac 上呢?
我尝试了一些类似于 locate Rcpp 的命令,但没有得到有用的信息。
R 是通过 homebrew 安装的,OSX 版本是 10.9(Mavericks)。
3个回答

38

使用.Library可以获取默认的库位置。
使用.libPaths("your/path")还可以获取/设置库树(参见?.libPaths)。
使用getwd()setwd("your/path")可以获取/设置工作目录。


非常好。我得到了这个:[1] "/usr/local/Cellar/r/3.1.1/R.framework/Resources/library" - qed
1
@qed 你可能是用Homebrew安装的。 - IRTFM

11
你可以使用函数find.package来查找一个或多个包的路径。
示例(查找R库rj的路径):
> find.package('rj')
[1] "\\\\nas/users/dernoncourt/Documents/dernoncourt/R/win-library/3.4/rj"

你也可以使用packageDescription。例如:

> packageDescription("rj")
Encoding: UTF-8
Package: rj
Version: 2.1.0-13
Title: RJ - R Package for high-level Java-R library RJ
Author: Stephan Wahlbrink, Tobias Verbeke, low-level R binding based on the JRI library by Simon Urbanek
Maintainer: Stephan Wahlbrink <stephan.wahlbrink@walware.de>
Depends: R (>= 2.11.0)
Suggests: rj.gd
SystemRequirements: java
Description: Server implementation and R functions for the high-level Java-R library RJ.  The package also includes callback functions for StatET.  It is shipped with an adapted version of the JRI library.  The package can be used only when R was loaded via RJ.
License: LGPL (== 2.1)
URL: http://www.walware.de/goto/opensource
NeedsCompilation: yes
Packaged: 2017-05-10 08:22:44 UTC; build
Built: R 3.4.0; x86_64-w64-mingw32; 2017-05-10 08:25:27 UTC; windows

-- File: \\nas/users/dernoncourt/Documents/dernoncourt/R/win-library/3.4/rj/Meta/package.rds 

9

你能看一下 /Library/Frameworks/R.framework/Resources/library 吗?


1
如果它是由默认的软件包系统安装的,那么它应该在/.../R.framework//Versions/2.15/Resources/library或者将2.15替换为3.0或Current。 - IRTFM

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接