首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在R中安装主题模型包?

如何在R中安装主题模型包?
EN

Stack Overflow用户
提问于 2014-06-11 20:40:26
回答 2查看 8.9K关注 0票数 15

我正试图在R中安装名为拓扑模型的软件包,但我没有成功。这是我尝试过的..。

操作:使用install.packages("topicmodels")安装包

结果:

代码语言:javascript
复制
package ‘topicmodels’ is available as a source package but not as a binary

Warning in install.packages :
  package ‘topicmodels’ is not available (for R version 3.1.0)

所以我说好的,让我们从源头安装

行动:install.packages("/Users/my_name/Downloads/topicmodels_0.2-1.tar.gz",repos=NULL,type="source")

结果:

代码语言:javascript
复制
* installing *source* package ‘topicmodels’ ...
** package ‘topicmodels’ successfully unpacked and MD5 sums checked
** libs
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c cokus.c -o cokus.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c common.c -o common.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c ctm.c -o ctm.o
ctm.c:29:10: fatal error: 'gsl/gsl_rng.h' file not found

include gsl/gsl_rng.h

1 error generated.
make: *** [ctm.o] Error 1
ERROR: compilation failed for package ‘topicmodels’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/topicmodels’
Warning in install.packages :
  installation of package ‘/Users/me/Downloads/topicmodels_0.2-1.tar.gz’ had non-zero exit status

于是我研究了gsl这件事,发现了此链接。现在,我认为我所有的问题都解决了,当我最终遵循这些指示的时候。我得到以下错误(在终端).

代码语言:javascript
复制
Warning in untar2(tarfile, files, list, exdir, restore_times) :
  using pax extended headers
ERROR: cannot extract package from ‘topicmodels.tar.gz’
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-06-16 13:49:24

首先,您必须安装gsl。一旦您安装了,您可以尝试安装R包。您可以从这里下载gsl (在那里您可以选择最新版本的gsl-latest.tar.gz)。下载之后,执行以下操作来安装它:

  1. 解压缩下载的文件(在我的例子中,“最新”文件包含以下版本:gsl-1.16)
  2. 打开“航站楼”
  3. 然后(使用终端),移动到您在步骤1中创建的文件夹中。
  4. 一旦您在该文件夹中,运行以下命令(按顺序排列): ./配置
  5. 这样做之后,您将不会得到前面提到的fatal error: 'gsl/gsl_rng.h' file not found错误,所以您可以重试安装。
  6. 现在回到您的R环境(例如,RStudio),再次尝试通过以下步骤安装该软件包: install.packages("PATH_TO_TOPIC_MODELS.tar.gz",repos=NULL,type="source")。

我也有同样的问题,在这样做后,我得到了正确的R包安装,我希望它也能在你的情况下工作。

票数 24
EN

Stack Overflow用户

发布于 2015-09-13 14:40:24

如果你已经用了自制的。与从源手动安装gsl相比,使用变量修复更好、更快。

  1. 用自制brew install gsl安装gsl
  2. 编辑~/.R/Makevars并添加。 PKG_LIBS=-L/usr/local/opt/gettext/lib CFLAGS=-I/usr/local/opt/gsl/include LDFLAGS=-L/usr/local/opt/gsl/lib -lgsl -lgslcblas
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24172188

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档