如何在 R 中安装 topicmodels 包? [英] How can I install topicmodels package in R?

查看:22
本文介绍了如何在 R 中安装 topicmodels 包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 R 和我中安装名为 topicmodels 的包没有成功.这是我尝试过的...

I am trying to install the package called topicmodels in R and I have not had success. Here's what I have tried...

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

结果:

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)

所以我说好的让我们从源代码安装

So there I said okay let's install from source

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

结果:

* 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 的东西并找到了 这个链接.目前我认为我所有的问题都消失了,当我最终按照这些指示进行时.我收到以下错误(在终端中)...

So then I researched this gsl thing and came upon this link. And for the moment I thought all of my problems were gone and when I finally follow these directions. I get the following error (in the terminal)...

Warning in untar2(tarfile, files, list, exdir, restore_times) :
  using pax extended headers
ERROR: cannot extract package from ‘topicmodels.tar.gz’

推荐答案

首先你必须安装 gsl.安装完成后,您可以尝试安装 R 包.你可以从这里下载gsl(在那里你可以选择最新版本gsl-latest.tar.gz).下载完成后,请执行以下操作进行安装:

First of all you have to install gsl. Once you have that installed you can try to install the R package. You can download gsl from here (there you can pick the latest version gsl-latest.tar.gz). Once it's been downloaded, install it by doing the following:

  1. 解压下载的文件(就我而言,最新"文件包含此版本:gsl-1.16)
  2. 打开终端"
  3. 然后(使用终端),移动到您在第 1 步中创建的文件夹内.在我的情况下,我在名为下载"的文件夹中有文件,所以我通过执行以下操作移动到新创建的文件夹:

  1. Decompress the downloaded file (in my case the "latest" file contained this version: gsl-1.16)
  2. Open the "Terminal"
  3. Then (using the Terminal), move inside the folder that you created on step 1. In my case I had the file on the folder called "Downloads", so I moved to the newly created folder by doing:

cd Downloads/gsl-1.16

  • 进入该文件夹后,运行以下命令(按顺序):

  • Once you are within that folder run the following commands (in order):

    ./configure
    make
    sudo make install
    

  • 完成后,您将不会收到之前的错误信息,提示 fatal error: 'gsl/gsl_rng.h' file not found,因此您可以再次尝试安装.

  • After doing it you won't get the previous error saying fatal error: 'gsl/gsl_rng.h' file not found, so you can try again the installation.

    现在返回到您的 R 环境(例如 RStudio),通过执​​行以下操作再次尝试安装包:

    Now go back to your R environment (e.g., RStudio) to try again to install the package by doing:

    install.packages("PATH_TO_TOPIC_MODELS.tar.gz", repos=NULL, type="source").
    

  • 我遇到了同样的问题,完成此操作后我正确安装了 R 包,希望它也适用于您的情况.

    I had the same problem, and after doing this I got the R package correctly installed, I hope it also works in your case.

    这篇关于如何在 R 中安装 topicmodels 包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆