Solving dependency ‘slam’ is not available and updating R in RStudio

During installation of tm package, I had a problem with dependency package slam.

> install.packages("tm")
Warning in install.packages :
dependency ‘slam’ is not available


When I load a tm library, there is an error.

> library(tm)
Loading required package: NLP
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
there is no package called ‘slam’



I tried to install slam package with different installation methods, but it did not work.
The problem was version incompatibility between R and slam package. It looks slam package requires higher than 3.3.0 version of R.
I checked my R version.

> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

...

Now I need to update my R version. installr package helps to update R through the RStudio.

> install.packages("installr")
> library(installr)

Checking updates and installing the final version of R.

> check.for.updates.R()
> install.R()

After restarting RStudio, I checked R version, and it is updated.

> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

...

Next, I install tm again and try to load it.

> install.package("tm")
...
package ‘NLP’ successfully unpacked and MD5 sums checked
package ‘Rcpp’ successfully unpacked and MD5 sums checked
package ‘slam’ successfully unpacked and MD5 sums checked
package ‘BH’ successfully unpacked and MD5 sums checked
package ‘tm’ successfully unpacked and MD5 sums checked
...


> library(tm)

   As you may have noticed, all dependency packages have been installed and tm loaded without error. Please note that when you update your R version, you need to install all packages again for this particular version.
   Thank you for reading, I hope you've found this post useful!

5 comments:

  1. Thank you. I've searched around to see why tm package was complaining about 'Corpus', and your solution here is the only one that helped.

    ReplyDelete
  2. in my case R version has updated but getting same issue. Any suggessions....

    ReplyDelete
    Replies
    1. RStudio need to be restarted after the update. Have you tried it?

      Delete
  3. ya but still same issues

    ReplyDelete