How can I install topicmodels package in R?

前端 未结 2 547
刺人心
刺人心 2020-12-29 08:43

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

Action: Install the package using install.p

相关标签:
2条回答
  • 2020-12-29 09:40

    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. 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
      
    4. Once you are within that folder run the following commands (in order):

      ./configure
      make
      sudo make install
      
    5. 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.

    6. 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").
      

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

    0 讨论(0)
  • 2020-12-29 09:40

    If you already using homebrew. It is better and faster to fix with variables than installing gsl manually from source.

    1. Install gsl with homebrew brew install gsl
    2. Edit ~/.R/Makevars and add.

      PKG_LIBS=-L/usr/local/opt/gettext/lib
      CFLAGS=-I/usr/local/opt/gsl/include
      LDFLAGS=-L/usr/local/opt/gsl/lib -lgsl -lgslcblas

    0 讨论(0)
提交回复
热议问题