25

I was able to use the library(tm) in r without problem until today, when loading tm shows:

library(tm)

Loading required package: NLP

Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :

there is no package called ‘slam’

Error: package or namespace load failed for ‘tm’

I thought this is a dependency issue and seek to reinstall package

install.packages("tm")

Warning in install.packages : dependency ‘slam’ is not available

and then try to find slam:

install.packages("slam")

Warning in install.packages :

package ‘slam’ is not available (for R version 3.2.4)

I also tried some of the issues listed here and chooseCRANmirror(), still no luck. Is there something wrong with the package or is it just that my r does not allow 'slam' to install after today?

session info

> sessionInfo()
R version 3.2.4 (2016-03-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] NLP_0.1-9

loaded via a namespace (and not attached):
[1] parallel_3.2.4 tools_3.2.4 
Community
  • 1
  • 1
Carl H
  • 1,036
  • 2
  • 15
  • 27
  • 1
    whats your sessionInfo? – Cyrus Mohammadian Oct 05 '16 at 23:57
  • Just asked, though not solved: http://stackoverflow.com/questions/39884276/r-compilation-failed-for-package-slam – alistaire Oct 06 '16 at 00:08
  • @CyrusMohammadian do you mean running `sessionInfo(package='slam')`? The result is "Error: $ operator is invalid for atomic vectors In addition: Warning message: In FUN(X[[i]], ...) : no package 'slam' was found" – Carl H Oct 06 '16 at 00:24
  • @alistaire thanks! will keep an eye on that thread too, I am operating on OSX – Carl H Oct 06 '16 at 00:24
  • No I meant, what environment are you working with? ``sessionInfo()`` – Cyrus Mohammadian Oct 06 '16 at 00:25
  • 1
    @CyrusMohammadian thanks for the edits, I have updated the question with my `sessionInfo()` – Carl H Oct 06 '16 at 00:27
  • 3
    I would suggest upgrading to the newest R release. – Cyrus Mohammadian Oct 06 '16 at 00:28
  • Thanks! It's now solved after updating R to 3.3.1 and then `install.packages("tm", dependencies = TRUE)` – Carl H Oct 06 '16 at 00:49
  • 1
    That's odd. The current version of slam on CRAN fails the tests for OS X because with an error that it cannot be installed. https://www.r-project.org/nosvn/R.check/r-release-osx-x86_64-mavericks/slam-00check.html – pdb Oct 06 '16 at 01:09
  • @pdb so this solution doesn't work for you? that's weird indeed... I'm on a different OS X system but it shouldn't make the difference I suppose.. – Carl H Oct 06 '16 at 13:04
  • My post said that it didn't work for CRAN's test machine. When i ran install.packages("slam") I had to choose a version. If I chose to install from source it fails (this matches CRAN's results). The install binary version worked for me but gets you the previous version. Was your experience different? – pdb Oct 07 '16 at 01:53
  • After reinstalling `tm` with `dependencies = True` I did not have to choose a version to install. – Carl H Oct 07 '16 at 02:34

13 Answers13

38

For R-version 3.2.3, following worked fine as mentioned in this link and it suggests this works for R-version 3.3.0 as well:

#install devtools if you have not installed 
install.packages('devtools')
library(devtools)

slam_url <- "https://cran.r-project.org/src/contrib/Archive/slam/slam_0.1-37.tar.gz"
install_url(slam_url)
Community
  • 1
  • 1
niraj
  • 17,498
  • 4
  • 33
  • 48
  • 2
    Had to also install Rtools and then it worked. Not sure if Rtools can be used instead of devtools. – Simone Jun 22 '17 at 18:32
  • @Simone thanks! for the comment. May be it will helpful someone who may have similar issue. – niraj Jun 22 '17 at 18:41
34

I found a hint at this german site about R under Install additional R packages ("Zusätzliche R-Pakete installieren") After I installed slam seperatly over apt-get for example:

sudo apt-get install r-cran-slam

I could install tm the normal way:

install.packages('tm')

And load the library aswell.

I hope my answer helps someone.

Onagon
  • 341
  • 2
  • 2
5

I had the same problem as you.
Slam "Depends: R (≥ 3.3.1)", this why I had to perform the following actions to successfully install and load "tm" package:

  1. Update R from 3.2.5 to the latest version 3.3.2
  2. install.packages("tm")
    also installing the dependencies ‘NLP’, ‘slam’ package ‘NLP’ successfully unpacked and MD5 sums checked package ‘slam’ successfully unpacked and MD5 sums checked package ‘tm’ successfully unpacked and MD5 sums checked

  3. library(tm)

M.M.
  • 51
  • 3
  • 2
    I tried installing it. It says "package ‘slam’ is not available (for R version 3.2.5)" That happened while installing package for tm. It did install NLP as the dependency. And not throws error(of course) if i try to run anything related to these libraries. – aman_novice Dec 07 '16 at 06:58
5

I used the following code to install the binary or the older version of slam. It worked for me.

install.packages("slam", type = "binary")
user6793824
  • 141
  • 2
  • 3
2

I had the same problem and:

  • I upgraded RStudio to the latest version (1.0.143)
  • I upgraded R to the latest version (R.3.3.3)
  • I rebooted Rstudio
  • I installed again in RStudio the package "tm"
  • I ran library(tm)

and everything works fine now.

Adam
  • 4,445
  • 1
  • 31
  • 49
Eduardo
  • 81
  • 4
2

The latest version of the package "slam" only works for R(>=3.4.0),so you can try either updating your R to the latest version or downloading an early version of the "slam" package.

This is a download link from CRAN for early version of "slam" package: https://cloud.r-project.org/bin/macosx/mavericks/contrib/3.3/slam_0.1-40.tgz.

Jack Sun
  • 21
  • 2
1

Apparently the problem seems to be the version of R you are using. Try installing the latest version of R, 3.3.1. That should take care of it.

AlxRd
  • 285
  • 1
  • 16
1

I am using R3.2.5. I was trying to install "tm". I did install NLP as a dependency but gave me an error :

"package ‘slam’ is not available (for R version 3.2.5)"

The option I had to was to download the zip/tar/gz file(binaries) from https://cran.r-project.org/web/packages/slam/index.html and install the package. It worked for me after that. Although I am not sure what the problem is because the library information mentions it is for R (≥ 3.3.1)

aman_novice
  • 1,027
  • 3
  • 13
  • 31
0

I also had to upgrade to the most recent version of R.

Specifically, on Ubuntu 16.04 here are instructions to get the up to date R version.

James Hirschorn
  • 7,032
  • 5
  • 45
  • 53
0

I faced this error while installing the "tm" package on R version 3.3.0. Seems like some missing libraries. After I could install the latest version 3.4.1 , i was able to install the package "tm" which installed the 'slam' on its own. Hope this may help somebody.

0
  1. Just Install NLP package with dependencies = True

  2. Install tm packaged with dependencies = True

And things should work out:)

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
saleem
  • 1
0

For Ubuntu, I installed the following two from console and then it got installed.

sudo apt-get install libblas-dev liblapack-dev

sudo apt-get install gfortran

Soumya Boral
  • 1,191
  • 14
  • 28
-3

For any such type of issue regarding package not installed, update your R and later reinstall the package. These are the steps you follow:

if(!require(installr)){ install.packages("installr")}

require(installr)}    #load the package

updateR()
John Moutafis
  • 22,254
  • 11
  • 68
  • 112