Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning while installing package in R

Tags:

r

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.

like image 422
JohnK Avatar asked Oct 25 '25 06:10

JohnK


1 Answers

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"))
like image 67
GSee Avatar answered Oct 26 '25 19:10

GSee