1
$\begingroup$

I've installed the R package tm. Now I am trying to load it, but it's giving me this error and warning everytime, I try.

The package is in this location-

‘C:/Users/Google/Documents/R/win-library/3.3’

Error Message--

Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  there is no package called ‘slam’
In addition: Warning message:
package ‘tm’ was built under R version 3.3.1 
Error: package or namespace load failed for ‘tm’

Any thoughts?

$\endgroup$
5
  • $\begingroup$ Can you please share the full code, including the suggestions below so that we can see what's going on? It appears to be a missing dependency for slam so if installing slam doesn't change anything that would be highly surprising. $\endgroup$
    – Hack-R
    Commented Aug 30, 2016 at 15:23
  • $\begingroup$ Also give your R version and the output from sessionInfo() $\endgroup$
    – Spacedman
    Commented Aug 30, 2016 at 15:52
  • $\begingroup$ I have tried all of the above recommendations - reinstalling latest versions of R and RStudio, installing and loading "pacman" package - and I am still unable to load the "slam" package. I am using R 3.3.1 via RStudio on my MacAir with macOS Sierra v10.12. In this regard, I am getting the following error messages regarding installing and REMOVING "slam" y/n: y installing the source package ‘slam’ trying URL 'cran.rstudio.com/src/contrib/slam_0.1-38.tar.gz' Content type 'application/x-gzip' length 49366 bytes (48 KB) ================================================== downloaded 48 KB * $\endgroup$
    – user25464
    Commented Oct 21, 2016 at 17:51
  • $\begingroup$ update r version to latest, it just worked for me. to do this, download latest version of R from cran and install it. no uninstall required for previous versions. Cheers! Manish $\endgroup$ Commented Jan 22, 2017 at 17:32
  • $\begingroup$ I just make sure all shipping and data information is correct to proceed with the package. $\endgroup$ Commented Feb 16, 2017 at 19:03

4 Answers 4

3
$\begingroup$

This is a dependency error. You're just missing one of the packages that tm assumes you have.

One solution is to simply directly install that package:

install.packages("slam")

another is to use a package manager that takes care of this for you:

install.packages("pacman")
pacman::p_load(tm)
$\endgroup$
4
  • 1
    $\begingroup$ Still getting the same error message. $\endgroup$
    – Abhishek
    Commented Aug 30, 2016 at 14:54
  • $\begingroup$ @AbhishekJaiswal Can you show the full code and error with the steps above? $\endgroup$
    – Hack-R
    Commented Aug 30, 2016 at 14:56
  • $\begingroup$ @AbhishekJaiswal OP? $\endgroup$
    – Hack-R
    Commented Aug 30, 2016 at 15:40
  • 1
    $\begingroup$ Hey, it worked after I reinstalled the R. Meanwhile, thanks for all your help. Cheers! :) $\endgroup$
    – Abhishek
    Commented Aug 31, 2016 at 15:38
0
$\begingroup$

This is related to the fact that the 'slam' package currently available on CRAN is dependent on a recent version of R (≥ 3.3.1). Updating R will solve the problem.

For those on Ubuntu wishing to keep the R version included in the repository, it is possible to install 'slam' as a package with

sudo apt-get install r-cran-slam
$\endgroup$
0
$\begingroup$

It worked after I reinstalled the R

. So I'll suggest to try doing this if anyone facing the same issue. Two of my mates also solved this issue by following the same approach.

Cheers!

$\endgroup$
3
  • 1
    $\begingroup$ True solution to your problem is not reinstalling R however reading the error message. When you tried to install tm you received an error message that slam is not known for the R version that you had. The solution is shown in this excellent post. Please note how this question is formatted. You are highly encouraged to follow the same approach as the OP in that latter question. $\endgroup$
    – Stereo
    Commented Oct 15, 2016 at 14:52
  • $\begingroup$ I got your point. I'll consider this for sure in answering any question. Thank you. Cheers! :) $\endgroup$
    – Abhishek
    Commented Oct 15, 2016 at 15:10
  • $\begingroup$ It is more about asking the question than answering but great that you got it. $\endgroup$
    – Stereo
    Commented Oct 15, 2016 at 15:39
0
$\begingroup$

In case someone bumps into the page looking for a solution. This one worked for me:

install.packages('devtools')
library(devtools)

Now install an earlier version of slam in case you are using an older version of R.

slam_old <- "https://cran.r-project.org/src/contrib/Archive/slam/slam_0.1-37.tar.gz"
install_url(slam_old)
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.