Search code examples
rggplot2viridis

viridis ggplot2 color package won't install , even with dependencies = TRUE


I boot up a clean instance of R Studio. I don't save my environments and I don't use an Rprofile file. I tried both commands:

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

and I get this error:

  • installing source package ‘viridis’ ... ** package ‘viridis’ successfully unpacked and MD5 sums checked ** R ** inst ** preparing package for lazy loading Error : object ‘cividis’ is not exported by 'namespace:viridisLite' ERROR: lazy loading failed for package ‘viridis’
  • removing ‘/home/stackinator/Rlibs/viridis’ Warning in install.packages : installation of package ‘viridis’ had non-zero exit status

Solution

  • Try the following:

    if (!require("devtools")) install.packages("devtools")
    devtools::install_github("sjmgarnier/viridis")
    

    I am not sure why downloading it from CRAN didn't work, but devtools::install_github() downloads the source package from the repository rather than the bundled package that you get from CRAN with install.packages()

    For more, check out this discussion from R Packages book: http://r-pkgs.had.co.nz/package.html