如何在R中安装topicmodels软件包? [英] How can I install topicmodels package in R?
问题描述
我正在尝试在R和I中安装名为 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:
- 解压缩下载的文件(在我的情况下,最新"文件包含以下版本:
gsl-1.16
) - 打开终端"
-
然后(使用终端)在步骤1中创建的文件夹内移动.对于我来说,我在名为"Downloads"的文件夹中拥有该文件,因此我通过执行以下操作移至新创建的文件夹:
- Decompress the downloaded file (in my case the "latest" file contained this version:
gsl-1.16
) - Open the "Terminal"
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屋!