2
votes

I have been trying to install the ggplot2 package in R and this is the warning I have been getting:

Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) : cannot open the connection

In addition: Warning messages:

1: In download.file(url, destfile, method, mode = "wb", ...) : downloaded length 1040720 != reported length 1152839

2: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file

3: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) : cannot open compressed file 'plyr/DESCRIPTION', probable reason 'No such file or directory'

It might be helpful to note that I am using the version 3.1.1. Could you please help me understand what went wrong and how I could resolve this?

Thank you in advance.

1
what command did you enter that generated that error? - GSee
@GSee install.packages("ggplot2"), that is all. - JohnK
Try install.packages("ggplot2", repos="http://cran.us.r-project.org") or install.packages("ggplot2", repos="http://cran.rstudio.org") - GSee
What is the output of getOption("repos")? - GSee
@Gsee The output is CRAN CRANextra "freestatistics.org/cran" "stats.ox.ac.uk/pub/RWin" - JohnK

1 Answers

5
votes

From the comments we discovered that somehow your repos option had been set to a bad value.

install.packages has an argument called repos that can be used to specify where to find the package that you'd like to install. If you specify a valid value, it should just work. e.g. you shouldn't get the error if you do this: install.packages("ggplot2", repos="http://cran.us.r-project.org")

If you do not provide a value, it will look at the repos option. See getOption("repos") to see what is set. In your case it was

                     CRAN                 CRANextra 
"freestatistics.org/cran" "stats.ox.ac.uk/pub/RWin" 

neither of which are valid URLs.

You can change the value of the repos option like this

options(repos=c(CRAN="@CRAN@", 
                CRANextra="http://www.stats.ox.ac.uk/pub/RWin"))