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)

Problems with loading ggplot2 - General, Error: package or namespace load failed for 'ggplot2' in loadNamespace (j <- i [[​1L]], c (lib.loc, .libPaths ()) r, ggplot2, data.table. asked by  Error: package or namespace load failed for ggplot2 and for data.table (8) After a wild goose chase with tons of Google searches and burteforce attempts, I think I found how to solve this problem.


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:

  1. Uninstall R
  2. Reinstall R
  3. Install ggplot with the dependencies argument to install.packages set to TRUE

    install.packages("ggplot2",dependencies = TRUE)

  4. 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

  1. 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

  1. 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`

  2. I was finally able to load the ggplot2 library successfully.

    library(ggplot2)

I can't load "ggplot2" in my library in R version 3.4.3, When I start to install "ggplot2" pacakages following this command on R studio library("ggplot2") Error: package or namespace load failed for /error-package-​or-namespace-load-failed-for-ggplot2-and-for-data-table… Browse other questions tagged r ggplot2 error-handling package rstudio or ask your own question. The Overflow Blog The Overflow #20: Sharpen your skills


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.

Error: package or namespace load failed for 'ggplot2', Loading required package: ggplot2 Error: package or namespace or namespace load failed for 'FactoMineR'" when using data mining on  Hello, I am presenting problems with ggplot2. I receive the following notice all the time: library (ggplot2) Error: package or namespace load failed for 'ggplot2' in loadNamespace (j <- i [[1L]], c (lib.loc, .libPath…


Faced same issue and solved by :

remove.packages("ggplot2")
install.packages('ggplot2', dependencies = TRUE)

ggplot2 is corrupt · Issue #36 · thomasp85/patchwork · GitHub, 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  library(ggraph) Error: package or namespace load failed for ‘ggraph’: object ‘scale_type’ is not exported by 'namespace:ggplot2' What does it mean? How can I fix it?


when you see

Do you want to install from sources the package which needs compilation? (Yes/no/cancel)

answer no

plotly was broken by ggplot2 update · Issue #1247 · ropensci/plotly , Hi @thomasp85 , Thanks for this awesome package. library(patchwork) Error: package or namespace load failed for 'patchwork' in get(Info[i,  Nothing worked. It does't work on version 3.4.4 or 3.5.0. In version 3.5.0 was another problem, there does not install data.table package (which is part of the package(car)) Error: package or namespace load failed for ‘car’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘data


Getting an error when loading ggplot2 : Rlanguage, This morning I updated ggplot2 as suggested by R and reinstalled But plotly didn't work but gave me an error message: Error: package or namespace load failed I tried to reinstall data.table but neither the install.packages  Also have had troubles, when installing ggplots2, but here is a curious solution (tested on windows): I installed via RStudio. Both from Tools->install packages and by typing install.packages("ggplots2", dep=T).


ggplot2 loading error, Error : package 'grid' does not have a namespace In addition: Warning under R version 3.0.3 Error: package or namespace load failed for 'ggplot2' Idk if any of this makes a difference, but: The dataset is combo of features and numerics. When I start to install "ggplot2" pacakages following this command on R studio 1.1.442, it gets installed but with following information shown in the console: &gt; library(&quot;ggplot2&quot;) Error: package or namespace load failed&hellip;


[R] Error: package or namespace load failed for 'g, I am trying to load cummeRbund library, it gave (Error: package 'ggplot2' could not be anyDuplicated, append, as.data.frame, as.vector, cbind, colnames, do.​call, under R version 3.2.5 Error: package or namespace load failed for '​ggplot2'. Confirm that I was able to install and load CRAN version for R 3.5.0 but loading development version (2ed76c3) threw error: Error: package or namespace load failed for ‘data.table’: package ‘data.table’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version 👍