R tm package will not load to R studio - r

I have been trying to load the tm text mining package onto R studio for a number of hours now. I have tried everything I have come across online but it doesnt appear to work.
I started with
install.packages('tm', dependencies = TRUE)
and am given the following error
Installing package into ‘D:/Users/byrne/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Warning in install.packages :
dependencies ‘slam’, ‘Rcampdf’, ‘Rgraphviz’, ‘Rpoppler’, ‘tm.lexicon.GeneralInquirer’ are not available
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/tm_0.6-2.zip'
Content type 'application/zip' length 710948 bytes (694 KB)
downloaded 694 KB
when i then try to load the package using
library(tm)
I get this error
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 have then loaded NLP and tried to load 'slam'. which it then tells me is not available on R version 3.2.3. I then updated to 3.2.5 and it still gives me the same message. I have changed the CRAN mirror to mutliple different locations and still get the same error.
Any help is greatly appreciated as I'm stumped now.

It is probably that 'slam' can not be installed because of '-lgfortran' package error. You need to apply below;
You need to close all R sessions also R Studio.
Open terminal and type xcode-select --install
Type curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
Type sudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /
You can install 'slam' now.

Try sudo apt-get install r-cran-slam on your terminal
It should work properly after that.

use command
install.packages("tm", repos="http://R-Forge.R-project.org")

Dependency package ‘slam’ is not available until R version 3.3.1 and you are using version 3.2.X.
Also, keep in mind that some of the dependency packages (like Rgraphviz) are no longer at the CRAN repository, but are at the Bioconductor site as explained in the answer to this question.

whenever it says "there is no package called ---", just install that package, restart your r session and this time it will load fine.

Related

R package updates

I have been having some issues accessing an updated version of a package in R.
On running a workflow for data analysis I got this error message:
library(dplyr)
Error: package or namespace load failed for ‘dplyr’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
namespace ‘rlang’ 0.2.1 is already loaded, but >= 0.2.2 is required
I therefore tried to update both the "dplyr" and "rlang" packages.
On updating I get the messages:
Installing package into ‘C:/Users/tomsp/OneDrive/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://cran.ma.imperial.ac.uk/bin/windows/contrib/3.5/rlang_0.2.2.zip'
Content type 'application/zip' length 820944 bytes (801 KB)
downloaded 801 KB
package ‘rlang’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘rlang’
The downloaded binary packages are in
C:\Users\tomsp\AppData\Local\Temp\RtmpmooXKa\downloaded_packages
However if I check the package using the code below it still has version 0.2.1
packageVersion("rlang")
[1] ‘0.2.1’
I checked my library paths and still have not managed to be run the latest version(0.2.2) of the package rlang.
Any advice of what I am doing wrong or how I can solve this?
Restart R and run install.packages again. On Windows, you can't update a package that's already loaded, if the package contains compiled C/C++/Fortran code. This includes dplyr and rlang.
To be doubly sure, before you run install.packages, go to your R packages directory (C:/Users/tomsp/OneDrive/Documents/R/win-library/3.5) and delete any zero-length files that are present. These are artifacts of failed install attempts and will break install.packages if present.
For any reason, at least in Windows, some R processes may still be running in background. Close your current R session, kill all processes related to R and try again.
If you are using Windows, check if the package you are trying to upgrade is available only as a source file.
If you try to install a package that needs compilation, you need the software Rtools. Download it on cran.r-project.org/bin/windows/Rtools/. Updating Rtools might also resolve your problem. The console message for a particular package is like that:
binary source needs_compilation
backports 1.2.0 1.2.1 TRUE
On Linux you don't need Rtools, but read the console output when you see an error when you try to install or update a package. If some software is missing, the error message on Linux is self-explanatory.
Deleted the entire library from R packages directory on my local computer. Installed again after terminating the session. Worked for me.

Error while installing package kableExtra in R

I am trying to install kableExtra and get the following errors:
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck =
vI[[j]]) :
there is no package called 'hms'
ERROR: lazy loading failed for package 'kableExtra'
*removing 'C:/Users/Tim/Documents/R/win-library/3.2/kableExtra'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.5/bin/x64/R" CMD INSTALL -l "C:\Users\Tim\Documents\R\win-library\3.2"
C:\Users\Tim\AppData\Local\Temp\RtmpUJQfwD/downloaded_packages/kableExtra_0.9.0.
tar.gz' had status 1
Warning in install.packages :
installation of package ‘kableExtra’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\Tim\AppData\Local\Temp\RtmpUJQfwD\downloaded_packages’
How can I solve my problem? Thanks in advance!
it seems kableExtra depends on the package "hms" so try install it before with:
install.packages("hms")
or via rstudio interface:
packages -> install
and type in "hms"
also try this command:
install.packages("kableExtra", dependencies = TRUE)
If there appear problems like installing rlang or something similar, there is no general solution for this. You can try to (re)install rtools. Sometimes there are missing parts of r installations. My guess if R can't install a dependencie is, that some library or tools of the R environment are missing or wrongly installed which have to be detected.
You have a trouble with the dependency with the package "hms". I have not got how you are installing the r package, but you can either install it first and then try it again or start the installation with the option of download and install all required dependencies, in the second option you need to be online and allow the package manager to intall what is required.
Here is how it looks in RGui. I guess your are not using RGui.

Errors installing/loading package ‘adespatial’

I am trying to run the dbmem function on a large dataset using the adespatial package, but cannot get it to install. When I run install.package("adespatial), I get this message:
package ‘adespatial’ is available as a source package but not as a binary.
Why can't I install this package as a binary and how do I go about getting this package installed on my Mac (OS sierra version 10.12.6). I am running R studio with R version 3.1.2
Update
I also tried running
install.packages("adespatial",type = "source")
however when I try to load the library it still says the library is not found. There were also many errors in the install. I updated my version of R to 3.4.4 and now it will install with a few errors, but the library still will not come up.
When I attempt to load the library (library(adespatial)), I receive this error:
Error: package or namespace load failed for ‘adespatial’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘curl’
Bit hard to replicate your problem, but try to install curl; either the R package:
install.packages("curl")
or directly on your OS (can't help there, sorry, never had an OS).
Anyway, if package installation fails in R, it throws an (or more) error message(s). In your case, they will point to missing packages. Rerun install.packages("adespatial") and see there.

Unable to install new R packages in DSX Desktop

I've just installed DSX Desktop with RStudio. I'm unable to load new packages, e.g. lubridate, and get the error below. If I check for package updates, I get the message "all packages are up-to-date", but the error below suggests it needs a newer version of Rcpp.
installing to /user-home/_global_/R/lubridate/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace ‘Rcpp’ 0.12.9.2 is already loaded, but >= 0.12.13 is required
ERROR: lazy loading failed for package ‘lubridate’
* removing ‘/user-home/_global_/R/lubridate’
Warning in install.packages :
installation of package ‘lubridate’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpIV4HWl/downloaded_packages’
I tried install.packages("Rcpp") which returned the message:
Error in unloadNamespace(pkg_name) :
namespace ‘Rcpp’ is imported by ‘httpuv’, ‘reshape2’, ‘tidyr’, ‘bindrcpp’, ‘tibble’, ‘htmltools’, ‘dplyr’, ‘plyr’ so cannot be unloaded
If I try remove.packages("Rcpp") or removing the packages above, I get the following message, and they remain in the Packages view.
Removing package from ‘/user-home/_global_/R’
(as ‘lib’ is unspecified)
Error in remove.packages : there is no package called ‘Rcpp’
Any advice please on how to proceed?
There seems to be a fundamental problem with RStudio. I encountered exactly the same problems you describe with the latest version (1.1.442). The problems are:
Packages viewed as out-of-date go into a loop when installing with a repeated error dialog box appearing.
The package version check refers out-of-date packages and will not install the current package versions showing on CRAN. This is due to RStudio pointing at a MRAN mirror that has old updates. This means that all packages stored there are out of date. You can see when the packages on MRAN were last updated here.
Removal of other packages (e.g. dependencies) doesn't work properly, and manual deletion of the folders doesn't solve the problem.
Inside Tools, Global options, Packages there is the ability to specify the mirror that should be used for package management. This doesn't seem to work.
I fixed my problem by going into R and performing a package update inside that. RStudio now uses the updated packages.
I have contacted RStudio about this and received the reply that they don't provide support for free versions of RStudio.
tl;dr: RStudio appears to be broken for updating packages. Use R itself for updates.
I was getting this error:
Windows 7, update.packages problem: “unable to move temporary installation”? Which I think was due to my antivirus, but not sure. MRAN version was 3.3.1 and this is what I would do to fix this error everytime I opened R-Studio and needed to install:
trace(utils:::unpackPkgZip, edit=TRUE)
# Edit line 142 - change Sys.sleep(2.5)
I was still having versioning issues with tidyverse, so looked around and decided to install the latest MRAN from Microsoft and that fixed all of my R-Studio versioning issues and install inssues. I had other issues where I was doing a work.
Version info:
Microsoft R Open 3.5.1
The enhanced R distribution from Microsoft
Default CRAN mirror snapshot taken on 2018-08-01.
Download Microsoft R Open 3.5.1

r error on installing colorspace for ggplot2

I am an r newbie and would appreciate some help installing ggplot2. I am using RStudio Version 0.98.1102. Please see error below.
install.packages("ggplot2")
runs fine
library("ggplot2")
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck =
vI[[i]]) : there is no package called ‘colorspace’ Error: package or
namespace load failed for ‘ggplot2’
install.packages("colorspace")
Installing package into ‘C:/Users/Jessica/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified) There is a binary version available (and
will be installed) but the source version is later: binary source
colorspace 1.2-4 1.2-5 trying URL
'...//cran.rstudio.com/bin/windows/contrib/3.1/colorspace_1.2-4.zip'
Warning in install.packages : cannot open: HTTP status was '404 Not
Found' Error in download.file(url, destfile, method, mode = "wb", ...)
: cannot open URL
'...://cran.rstudio.com/bin/windows/contrib/3.1/colorspace_1.2-4.zip'
Warning in install.packages : download of package ‘colorspace’ failed
Looks like something is a bit messed up with the package meta-information or something in your Rstudio installation. A simple work-around to try is to just download the latest colorspace zip file from here: http://cran.r-project.org/web/packages/colorspace/index.html
Then install by running install.packages("c:/path/to/downloaded/zip/file/colorspace_1.2-5.zip")
When you type in install.packages("ggplot2") into the console, RStudio is pre-programmed to also install the dependencies (i.e. the other packages ggplot needs to run properly). In this case, the issue appears to be with the colorspace package not being able to installed. This is likely because you're running Yosemite and when RStudio looks to install colorspace, it searches for it on the CRAN, it can't find it for some reason:
cannot open URL 'http://cran.rstudio.com/bin/macosx/mavericks/contrib/3.1/colorspace_1.2-4.tgz'
You should be able to overcome this by installing the colorspace package yourself via the CRAN: http://cran.r-project.org/web/packages/colorspace/index.html.
Similar to the original question, I recently encountered this issue with colormap 2.0.0, ggplot2 3.3.2, R 4.0.3, and RStudio 1.3.1093 on Windows. install.packages("ggplot2") reports success even though it does not install colormap and library(ggplot2) therefore fails. In my case, install.packages("colormap") failed to locate the 2.0.0 binaries, retrieving the 1.4.1 sources instead. Downloading the 2.0.0 binary from https://CRAN.R-project.org/package=colorspace, as suggested in other answers, failed with
> install.packages("C:/Users/<username>/Downloads/colorspace_2.0-0.zip") # note use of forward slashes to avoid the backlash escaping problems #Paul M mentions in his comment on #L P's answer -- \\ instead of just \ also works
Warning in install.packages :
package ‘C:/Users/<username>/Downloads/colorspace_2.0-0.zip’ is not available for this version of R
What resolved this for me was including type = "win.binary" in install.packages()'s arguments when installing from the download.
install.packages("C:/Users/<username>/Downloads/colorspace_2.0-0.zip", type = "win.binary")
Having done this, install.packages("colorspace") also succeeds (both in session and after remove.packages("colorspace") and restarting R).
Try to install the color space separately and reload the package inside R studio again .
install.packages('ggplot2')
install.packages('colorspace')
library(ggplot2)
Hope this helps!
Sometimes when the Curl version is not updated, problem with installing the packages happens. For resolving the problem in Linux, you could use the following command to update your Curl to tha last version:
sudo apt-get install libcurl4-openssl-dev libxml2-dev
To me, it started giving this error when I updated all my packages using the available option "Packages" in R studio, it was working well before. After trying a few mentioned solutions in google and failed, I updated my R version and installed the packages, it worked.

Resources