Search code examples
rggplot2install.packages

Unable to use ggplot2


Getting below error while trying to install and use ggplot2

install.packages("ggplot2")

library(ggplot2)
Error: package or namespace load failed for ‘ggplot2’ in
  loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck =
  vI[[j]]):  there is no package called ‘Rcpp’ In addition: Warning
  message: package ‘ggplot2’ was built under R version 3.4.3

Solution

  • Please perform the below mentioned steps

    1) install.packages("Rcpp")

    Installing package into ‘C:/Users/username/Documents/R/win-library/3.4’
    (as ‘lib’ is unspecified)
    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/Rcpp_0.12.14.zip'
    Content type 'application/zip' length 4358875 bytes (4.2 MB)
    downloaded 4.2 MB
    
    package ‘Rcpp’ successfully unpacked and MD5 sums checked
    Warning in install.packages :
      unable to move temporary installation ‘C:\Users\username\Documents\R\win-library\3.4\file173429377309\Rcpp’ to ‘C:\Users\username\Documents\R\win-library\3.4\Rcpp’
    
    The downloaded binary packages are in
        C:\Users\username\AppData\Local\Temp\RtmpQJ4SRf\downloaded_packages
    

    2) Goto C:\Users\username\AppData\Local\Temp\RtmpQJ4SRf\downloaded_packages

    3) Extract Rcpp_0.12.14.zip to C:\Users\username\Documents\R\win-library\3.4

    4) library(ggplot2)