gpt4 book ai didi

r - 如何在 R 中安装 topicmodels 包?

转载 作者:行者123 更新时间:2023-12-03 21:17:51 25 4
gpt4 key购买 nike

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

行动:
使用 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)

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

行动: 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 的东西并发现了 this link .目前我认为我所有的问题都消失了,当我最终按照这些指示进行时。我收到以下错误(在终端中)...
Warning in untar2(tarfile, files, list, exdir, restore_times) :
using pax extended headers
ERROR: cannot extract package from ‘topicmodels.tar.gz’

最佳答案

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

  • 解压缩下载的文件(在我的情况下,“最新”文件包含此版本:gsl-1.16)
  • 打开“终端”
  • 然后(使用终端),移动到您在第 1 步中创建的文件夹内。在我的情况下,我在名为“下载”的文件夹中有文件,所以我通过执行以下操作移动到新创建的文件夹:
    cd Downloads/gsl-1.16
  • 进入该文件夹后,运行以下命令(按顺序):
    ./configure
    make
    sudo make install
  • 这样做后,您将不会收到之前的错误信息 fatal error: 'gsl/gsl_rng.h' file not found ,以便您可以再次尝试安装。
  • 现在返回到您的 R 环境(例如,RStudio)通过执行以下操作再次尝试安装包:
    install.packages("PATH_TO_TOPIC_MODELS.tar.gz", repos=NULL, type="source").

  • 我遇到了同样的问题,这样做后我正确安装了 R 包,我希望它也适用于您的情况。

    关于r - 如何在 R 中安装 topicmodels 包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24172188/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com