R: Problems with unloadNamespace(package) when installing a package - r

I made an R-package called TRIMmaps and tried to install it with the command
R CMD INSTALL TRIMmaps_v1.12.0
I received the following error message:
Error in unloadNamespace(package) :
namespace ‘Rcpp’ is imported by ‘plyr’ so cannot be unloaded
Error in library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) :
“Rcpp” version 0.11.2 cannot be unloaded.
I do need package plyr, however, because when I remove it I get the message:
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
there is no package called ‘plyr’
I removed both packages plyr and Rcpp and installed them again. My current version of Rcpp now is 0.11.5, but when I try to install the TRIMmaps-package again, I get the same error message as above including the line “Rcpp” version 0.11.2 cannot be unloaded. Although I have removed the older Rcpp-version and replaces it by 0.11.5, here still a problem occurs with 0.11.2.
How do I solve this? Any hint is appreciated.

I get a similar error. Minimal conditions to reproduce it seem to be:
Depend on a package x (in my case reshape)
In your vignette load a packge y (in my case plyr) that also imports or depends on x.
The vignette builds fine if you build it outside of the package building or checking process, but throws the error that you indicate otherwise. The error is also R version and maybe site specific, since it goes away with R 3.2.0 when trying to build the package on a different machine.

The easiest way is to close (R-Studio), or open a new (GUI), and do the job, and you can copy your code and reuse them.

**#This package is not installed ,but use tamp :
install.packages("tamp", dependencies=TRUE)
If you mean TRIM MAP SITE:
https://www2.gov.bc.ca/gov/content/data/geographic-data-services/topographic-data/raster-base-maps
#derderi**

In search box, type command prompt
In the command prompt, change directory to the place that contains the R package.
Build R package using R CMD build pkgName. For example I use R CMD build cum*. A tar.gz
The file is built under the working directory.
There's a PDF Tutorial that goes more in-depth.

Related

Error 'there is no package called 'rio'' when using fviz_dend and fviz_cluster

I'm running an ACP on a dataset and when I tried to use fviz_dend or fviz_cluster on the hcpc result it returns this error:
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck =
vI[[i]]): there is no package called 'rio'
Libraries FactoMineR and factoextra are loaded, ggplot2 as well.
I tried to install rio package but I had another error:
Warning message: "dependency 'foreign' is not available"
There is a binary version available but the source version is later:
binary source needs_compilation rio 0.5.26 0.5.27 FALSE
installing the source package 'rio'
Warning message in install.packages("rio"): "installation of package
'rio' had non-zero exit status"
After that when I try to install library('rio') it returns an error :
there is no package called 'rio'
I've read the fviz_dend documentation and it never mention any rio.
What can I do to avoid this problem?
It looks like rio is a dependency of both FactoMineR and factoextra. You can see if this by running the following line.
library(packrat)
packrat:::recursivePackageDependencies("FactoMineR",lib.loc = .libPaths()[1])
#[79] "purrr" "quantreg" "readr" "readxl" "rematch" "rio"
The error might be dependent on your operating system, so probably need to see the full error message. You may not have the proper tools (like cmake, which you would need to install on your command line) installed on your system.
Thanck you for your help :)
I was using a jupyter notebook, now I've transfered my work on R studio and there is no more issue. I think it was linked to the operating system as you said.

Error message: loadNamespace(name): there is no package called ‘yaml’ [duplicate]

I am not able to open install the ggplot2 and data.table packages.
It gives me the following error (example for ggplot2)
> library(ggplot2)
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘Rcpp’
Error: package or namespace load failed for ‘ggplot2’
I was able to work fine with these 2 packages before I closed my R session. Now it shows me this error each time I try to run it.
I have also tried to remove and re-install it, but without success.
remove.packages(c("ggplot2", "data.table"))
install.packages('ggplot2', dep = TRUE)
install.packages('data.table', dep = TRUE)
I am not sure what's wrong
This solved the issue:
remove.packages(c("ggplot2", "data.table"))
install.packages('Rcpp', dependencies = TRUE)
install.packages('ggplot2', dependencies = TRUE)
install.packages('data.table', dependencies = TRUE)
After a wild goose chase with tons of Google searches and burteforce attempts, I think I found how to solve this problem.
Steps undertaken to solve the problem:
Uninstall R
Reinstall R
Install ggplot with the dependencies argument to install.packages set to TRUE
install.packages("ggplot2",dependencies = TRUE)
The above step still does NOT include the Rcpp dependency so that has to be manually installed using the following command
install.packages("Rcpp")
However, while the above command successfully downloads Rcpp, for some reason, it fails to explode the ZIP file and install it in my R's library folder citing the following error:
package ‘Rcpp’ successfully unpacked and MD5 sums checked Warning in
install.packages : unable to move temporary installation
‘C:\Root_Prgs\Data_Science_SW\R\R-3.2.3\library\file27b8ef47b6d\Rcpp’
to ‘C:\Root_Prgs\Data_Science_SW\R\R-3.2.3\library\Rcpp’
The downloaded binary packages are in
C:\Users\MY_USER_ID\AppData\Local\Temp\Rtmp25XQ0S\downloaded_packages
Note that the above output says "Warning" but actually, it is an indication of failure to install the Rcpp package successfully within the repository. I then used the Tools-->Install packages--> From ZIP file and pointed to the location of the "downloaded binary packages" in the message above -
C:\Users\MY_USER_ID\AppData\Local\Temp\Rtmp25XQ0S\downloaded_packages\Rcpp_0.12.3.zip
This led to successful installation of Rcpp in my R\R-3.2.3\library folder, thereby ensuring that Rcpp is now available when I attempt to load the library for ggplot2. I could not do this step in the past because my previous installation of R would throw error stating that Rcpp cannot be imported. However, the same command worked after I uninstalled and reinstalled R, which is ODD.
install.packages("C:/Users/MY_USER_ID/AppData/Local/Temp/Rtmp25XQ0S/downloaded_packages/Rcpp_0.12.3.zip", repos = NULL, type = "win.binary")
package ‘Rcpp’ successfully unpacked and MD5 sums checked`
I was finally able to load the ggplot2 library successfully.
library(ggplot2)
Faced same issue and solved by :
remove.packages("ggplot2")
install.packages('ggplot2', dependencies = TRUE)
I also faced the same problem and
remove.packages(c("ggplot2", "data.table"))
install.packages('Rcpp', dependencies = TRUE)
install.packages('ggplot2', dependencies = TRUE)
these commands did not work for me. What I found was that it was showing a warning message that it could not move temporary installation C:\Users\User_name\Documents\R\win-library\3.3\abcd1234\Rcpp to C:\Users\User_name\Documents\R\win-library\3.3\Rcpp.
I downloaded the Rcpp zip file from the link given and unziped it and copied it inside C:\Users\User_name\Documents\R\win-library\3.3 and then
library(Rcpp)
library(ggplot2)
worked. I did not have to uninstall R. Hope this helps.
when you see
Do you want to install from sources the package which needs compilation? (Yes/no/cancel)
answer no
Try this:
install.packages('Rcpp')
install.packages('ggplot2')
install.packages('data.table')
I had the same problem with the package "tidyverse". I solved the problem with
1. uninstalling the package "Rcpp" and "tidyverse"
2. reinstalling "Rcpp" and answering the following questions during the installation process:
Do you want to install from sources the package which needs compilation? (Yes/no/cancel)
with
no
reinstalling "tidyverse".
I tried the steps mentioned in the earlier posts but without any success. However, what worked for me was uninstalling R completely and then deleting the R folder which files in the documents folder, so basically everything do with R except the scripts and work spaces I had saved. I then reinstalled R and ran
remove.packages(c("ggplot2", "data.table"))
install.packages('Rcpp', dependencies = TRUE)
install.packages('ggplot2', dependencies = TRUE)
install.packages('data.table', dependencies = TRUE)
This rather crude method somehow worked for me.
I tried all the listed solutions above but nothing worked.
This is what worked for me.
Look at the complete error message which you get when you use library(ggplot2).
It lists a couple of packages which are missing or have errors.
Uninstall and reinstall them.
ggplot should work now with a warning for version.
These steps work for me:
Download the Rcpp manually from WebSite
(https://cran.r-project.org/web/packages/Rcpp/index.html)
unzip the folder/files to "Rcpp" folder
Locate the "library" folder under R install directory Ex:
C:\R\R-3.3.1\library
Copy the "Rcpp" folder to Library folder.
Good to go!!!
library(Rcpp)
library(ggplot2)
For me, i had to uninstall R from brew brew uninstall --force R and then head over to the R website and download and install it from there.
I had this same problem, but when running in a jupyter R notebook in an Anaconda environment.
The problem presented in such a way that any R notebook opened would instantly die and would not allow cell execution. The error would show up with each failed automated attempt to start the kernel:
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘Rcpp’
To solve this, I ran as admin/sudo: conda install -c r r-rcpp, restarted the kernel, and everything was back to normal.
Sorry for joining the party late, You can install any package in RStudio by downloading the zip file from the CRAN website and running the below snippet in the console,
install.packages('~/Downloads/Rcpp_1.0.8.tgz', repos = NULL, type = 'source')

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.

Revolution R Enterprise with R version 3.2.2 and caret package

I am using Revolution R Enterprise with R version 3.2.2 (2015-08-14)
when I am trying to installed library(caret) I got this error
library(caret)
Loading required package: ggplot2
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘Rcpp’
In addition: Warning messages:
1: package ‘caret’ was built under R version 3.2.5
2: package ‘ggplot2’ was built under R version 3.2.4
Error: package ‘ggplot2’ could not be loaded
please help me
I tried many things and every things but I still have this error
So, that warning is pretty common with R packages. It is just a disclosure of what version the package was tuned to when it was created. That does not mean the package did not install properly.So there are a few things that I do when this happens (and it happened to me at work today with the sp mapping package).
If you are in RStudio, use the tools to update all packages as well updating R itself, save everything in your script, close it up. Restart you entire computer.
Reinstall the packages you need with install.packages("packagename", dependencies= TRUE). If a package is dependent on another package, then you will catch it here.
Then go back through the console and see all of the dependent package names that installed with your new package and update those with dependencies=TRUE as well. It is possible the Rcpp is installed but needs another package to support your target package.
I would again properly quit R or RStudio and then reboot the computer again.
I know it seems like overkill, but it has worked miracles for me on many occasions. You need to start all the way at the beginning to make it happen.

Error: package or namespace load failed for ggplot2 and for data.table

I am not able to open install the ggplot2 and data.table packages.
It gives me the following error (example for ggplot2)
> library(ggplot2)
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘Rcpp’
Error: package or namespace load failed for ‘ggplot2’
I was able to work fine with these 2 packages before I closed my R session. Now it shows me this error each time I try to run it.
I have also tried to remove and re-install it, but without success.
remove.packages(c("ggplot2", "data.table"))
install.packages('ggplot2', dep = TRUE)
install.packages('data.table', dep = TRUE)
I am not sure what's wrong
This solved the issue:
remove.packages(c("ggplot2", "data.table"))
install.packages('Rcpp', dependencies = TRUE)
install.packages('ggplot2', dependencies = TRUE)
install.packages('data.table', dependencies = TRUE)
After a wild goose chase with tons of Google searches and burteforce attempts, I think I found how to solve this problem.
Steps undertaken to solve the problem:
Uninstall R
Reinstall R
Install ggplot with the dependencies argument to install.packages set to TRUE
install.packages("ggplot2",dependencies = TRUE)
The above step still does NOT include the Rcpp dependency so that has to be manually installed using the following command
install.packages("Rcpp")
However, while the above command successfully downloads Rcpp, for some reason, it fails to explode the ZIP file and install it in my R's library folder citing the following error:
package ‘Rcpp’ successfully unpacked and MD5 sums checked Warning in
install.packages : unable to move temporary installation
‘C:\Root_Prgs\Data_Science_SW\R\R-3.2.3\library\file27b8ef47b6d\Rcpp’
to ‘C:\Root_Prgs\Data_Science_SW\R\R-3.2.3\library\Rcpp’
The downloaded binary packages are in
C:\Users\MY_USER_ID\AppData\Local\Temp\Rtmp25XQ0S\downloaded_packages
Note that the above output says "Warning" but actually, it is an indication of failure to install the Rcpp package successfully within the repository. I then used the Tools-->Install packages--> From ZIP file and pointed to the location of the "downloaded binary packages" in the message above -
C:\Users\MY_USER_ID\AppData\Local\Temp\Rtmp25XQ0S\downloaded_packages\Rcpp_0.12.3.zip
This led to successful installation of Rcpp in my R\R-3.2.3\library folder, thereby ensuring that Rcpp is now available when I attempt to load the library for ggplot2. I could not do this step in the past because my previous installation of R would throw error stating that Rcpp cannot be imported. However, the same command worked after I uninstalled and reinstalled R, which is ODD.
install.packages("C:/Users/MY_USER_ID/AppData/Local/Temp/Rtmp25XQ0S/downloaded_packages/Rcpp_0.12.3.zip", repos = NULL, type = "win.binary")
package ‘Rcpp’ successfully unpacked and MD5 sums checked`
I was finally able to load the ggplot2 library successfully.
library(ggplot2)
Faced same issue and solved by :
remove.packages("ggplot2")
install.packages('ggplot2', dependencies = TRUE)
I also faced the same problem and
remove.packages(c("ggplot2", "data.table"))
install.packages('Rcpp', dependencies = TRUE)
install.packages('ggplot2', dependencies = TRUE)
these commands did not work for me. What I found was that it was showing a warning message that it could not move temporary installation C:\Users\User_name\Documents\R\win-library\3.3\abcd1234\Rcpp to C:\Users\User_name\Documents\R\win-library\3.3\Rcpp.
I downloaded the Rcpp zip file from the link given and unziped it and copied it inside C:\Users\User_name\Documents\R\win-library\3.3 and then
library(Rcpp)
library(ggplot2)
worked. I did not have to uninstall R. Hope this helps.
when you see
Do you want to install from sources the package which needs compilation? (Yes/no/cancel)
answer no
Try this:
install.packages('Rcpp')
install.packages('ggplot2')
install.packages('data.table')
I had the same problem with the package "tidyverse". I solved the problem with
1. uninstalling the package "Rcpp" and "tidyverse"
2. reinstalling "Rcpp" and answering the following questions during the installation process:
Do you want to install from sources the package which needs compilation? (Yes/no/cancel)
with
no
reinstalling "tidyverse".
I tried the steps mentioned in the earlier posts but without any success. However, what worked for me was uninstalling R completely and then deleting the R folder which files in the documents folder, so basically everything do with R except the scripts and work spaces I had saved. I then reinstalled R and ran
remove.packages(c("ggplot2", "data.table"))
install.packages('Rcpp', dependencies = TRUE)
install.packages('ggplot2', dependencies = TRUE)
install.packages('data.table', dependencies = TRUE)
This rather crude method somehow worked for me.
I tried all the listed solutions above but nothing worked.
This is what worked for me.
Look at the complete error message which you get when you use library(ggplot2).
It lists a couple of packages which are missing or have errors.
Uninstall and reinstall them.
ggplot should work now with a warning for version.
These steps work for me:
Download the Rcpp manually from WebSite
(https://cran.r-project.org/web/packages/Rcpp/index.html)
unzip the folder/files to "Rcpp" folder
Locate the "library" folder under R install directory Ex:
C:\R\R-3.3.1\library
Copy the "Rcpp" folder to Library folder.
Good to go!!!
library(Rcpp)
library(ggplot2)
For me, i had to uninstall R from brew brew uninstall --force R and then head over to the R website and download and install it from there.
I had this same problem, but when running in a jupyter R notebook in an Anaconda environment.
The problem presented in such a way that any R notebook opened would instantly die and would not allow cell execution. The error would show up with each failed automated attempt to start the kernel:
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘Rcpp’
To solve this, I ran as admin/sudo: conda install -c r r-rcpp, restarted the kernel, and everything was back to normal.
Sorry for joining the party late, You can install any package in RStudio by downloading the zip file from the CRAN website and running the below snippet in the console,
install.packages('~/Downloads/Rcpp_1.0.8.tgz', repos = NULL, type = 'source')

Resources