This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Errors about ggplot2 packages of R language install in Ubuntu server

Hello everyone

I tried to install ggplots packages of R in Ubuntu server, but there were some errors which displayed as follows:

Warning messages:
1:In install.packages("ggplot2"):
Installation of package 'plyr' had non-zero exit status

2: In install.packages("ggplot2"):
Installation of package 'reshape2' had non-zero exit status

3: In install.packages("ggplot2"):
Installation of package 'scales' had non-zero exit status

4: In install.packages("ggplot2"):
Installation of package 'ggplot2' had non-zero exit status

Then I tried to use ggplot2 through command:

library('ggplot2')

But terminal told me that

Error in library (ggplot2): there is no package called 'ggplot2'

I have found many information about this problem on internet, but no available ways find and error was error.

If you have some suggestion, please tell me.

Thanks for your help.

r ggplot2 ubuntu server

ggplot2 probably couldn't be installed because its dependencies couldn't be installed. What's the output of sessionInfo() and were you able to see the actual errors encountered during the installation of plyr et al.?

The output of sessionInfo() was listed here:

> sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=zh_CN.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=zh_CN.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C                 LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=zh_CN.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tcltk_2.14.1 tools_2.14.1
> sessionInfo(ggplot2)
Error in sessionInfo(ggplot2) : object 'ggplot2' not found
> sessionInfo('ggplot2')
Error: $ operator is invalid for atomic vectors
In addition: Warning message:
In FUN("ggplot2"[[1L]], ...) : no package 'ggplot2' was found

And the compete output of install.packages('ggplot2') as follows:

Installing package(s) into '/home/ginsea/R/x86_64-pc-linux-gnu-library/2.14'
(as 'lib' is unspecified)
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
Warning: dependency 'Rcpp' is not available
also installing the dependencies 'plyr', 'reshape2', 'scales'

trying URL 'http://mirrors.ustc.edu.cn/CRAN/src/contrib/plyr_1.8.1.tar.gz'">http://mirrors.ustc.edu.cn/CRAN/src/contrib/plyr_1.8.1.tar.gz'
Content type 'application/x-gzip' length 393233 bytes (384 Kb)
opened URL
==================================================
downloaded 384 Kb

trying URL 'http://mirrors.ustc.edu.cn/CRAN/src/contrib/reshape2_1.4.tar.gz'">http://mirrors.ustc.edu.cn/CRAN/src/contrib/reshape2_1.4.tar.gz'
Content type 'application/x-gzip' length 34121 bytes (33 Kb)
opened URL
==================================================
downloaded 33 Kb

trying URL 'http://mirrors.ustc.edu.cn/CRAN/src/contrib/scales_0.2.4.tar.gz'">http://mirrors.ustc.edu.cn/CRAN/src/contrib/scales_0.2.4.tar.gz'
Content type 'application/x-gzip' length 40093 bytes (39 Kb)
opened URL
==================================================
downloaded 39 Kb

trying URL 'http://mirrors.ustc.edu.cn/CRAN/src/contrib/ggplot2_1.0.0.tar.gz'">http://mirrors.ustc.edu.cn/CRAN/src/contrib/ggplot2_1.0.0.tar.gz'
Content type 'application/x-gzip' length 2351447 bytes (2.2 Mb)
opened URL
==================================================
downloaded 2.2 Mb

ERROR: dependency 'Rcpp' is not available for package 'plyr'
* removing '/home/ginsea/R/x86_64-pc-linux-gnu-library/2.14/plyr'
ERROR: dependencies 'plyr', 'Rcpp' are not available for package 'reshape2'
* removing '/home/ginsea/R/x86_64-pc-linux-gnu-library/2.14/reshape2'
ERROR: dependency 'plyr' is not available for package 'scales'
* removing '/home/ginsea/R/x86_64-pc-linux-gnu-library/2.14/scales'
ERROR: dependencies 'plyr', 'reshape2', 'scales' are not available for package 'ggplot2'
* removing '/home/ginsea/R/x86_64-pc-linux-gnu-library/2.14/ggplot2'

The downloaded packages are in
    '/tmp/Rtmpu4S6sr/downloaded_packages'
Warning messages:
1: In install.packages("ggplot2") :
  installation of package 'plyr' had non-zero exit status
2: In install.packages("ggplot2") :
  installation of package 'reshape2' had non-zero exit status
3: In install.packages("ggplot2") :
  installation of package 'scales' had non-zero exit status
4: In install.packages("ggplot2") :
  installation of package 'ggplot2' had non-zero exit status

I can't get in the web which you described here, so I pasted the complete output message of install.packages ('ggplot2') as follows:

Installing package(s) into '/home/ginsea/R/x86_64-pc-linux-gnu-library/2.14'
(as 'lib' is unspecified)
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
Warning: dependency 'Rcpp' is not available
also installing the dependencies 'plyr', 'reshape2', 'scales'

trying URL 'http://mirrors.ustc.edu.cn/CRAN/src/contrib/plyr_1.8.1.tar.gz'
Content type 'application/x-gzip' length 393233 bytes (384 Kb)
opened URL
==================================================
downloaded 384 Kb

trying URL 'http://mirrors.ustc.edu.cn/CRAN/src/contrib/reshape2_1.4.tar.gz'
Content type 'application/x-gzip' length 34121 bytes (33 Kb)
opened URL
==================================================
downloaded 33 Kb

trying URL 'http://mirrors.ustc.edu.cn/CRAN/src/contrib/scales_0.2.4.tar.gz'
Content type 'application/x-gzip' length 40093 bytes (39 Kb)
opened URL
==================================================
downloaded 39 Kb

trying URL 'http://mirrors.ustc.edu.cn/CRAN/src/contrib/ggplot2_1.0.0.tar.gz'
Content type 'application/x-gzip' length 2351447 bytes (2.2 Mb)
opened URL
==================================================
downloaded 2.2 Mb

ERROR: dependency 'Rcpp' is not available for package 'plyr'
* removing '/home/ginsea/R/x86_64-pc-linux-gnu-library/2.14/plyr'
ERROR: dependencies 'plyr', 'Rcpp' are not available for package 'reshape2'
* removing '/home/ginsea/R/x86_64-pc-linux-gnu-library/2.14/reshape2'
ERROR: dependency 'plyr' is not available for package 'scales'
* removing '/home/ginsea/R/x86_64-pc-linux-gnu-library/2.14/scales'
ERROR: dependencies 'plyr', 'reshape2', 'scales' are not available for package 'ggplot2'
* removing '/home/ginsea/R/x86_64-pc-linux-gnu-library/2.14/ggplot2'

The downloaded packages are in
    '/tmp/Rtmpu4S6sr/downloaded_packages'
Warning messages:
1: In install.packages("ggplot2") :
  installation of package 'plyr' had non-zero exit status
2: In install.packages("ggplot2") :
  installation of package 'reshape2' had non-zero exit status
3: In install.packages("ggplot2") :
  installation of package 'scales' had non-zero exit status
4: In install.packages("ggplot2") :
  installation of package 'ggplot2' had non-zero exit status

I had the same issue. Updated R to the latest version. Worked well. Thanks to all for the suggestions.

2 answers

You need to install Rcpp first. I'm a bit surprised this wasn't done automagically.

Thank you! sir!

I have solved it by uninstalling old R (sudo apt-get install r-base-core) and installing a new version (source code which download from R web) instead.

It seems that you are using a very old version R; so, even if you succeed in installing ggplot2, be aware that it may not work correctly afterwards. In any case, to solve the issue you should install Rcpp separately - e.g. sudo apt-get install r-cran-rcpp

Thank you ! sir !

You are right, my R version was really old, I solved the error by using a new R version which downloaded from R web.

Log in to answer this question.