Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to install packages in R -- Line starting '<!DOCTYPE HTML PUBLI ...' is malformed

I have been using R Studio for years without any issues but today I am not able to install any packages.

When I use the following code:

install.packages("dplyr")

I just get this message:

Error in install.packages : Line starting '<!DOCTYPE HTML PUBLI ...' is malformed!

I have tried different mirrors and updated my R Studio to the latest version without any joy. My internet connection hasn't changed and is operating normally.

Any help hugely appreciated!

like image 880
Thomas Deane Avatar asked Oct 31 '25 11:10

Thomas Deane


2 Answers

This suggests you are getting an http redirect from the server. Changing the repo ought to fix it. There are many different repos you can try. I find the following very reliable:

install.packages("dplyr", repos = c(CRAN = "https://www.stats.bris.ac.uk/R/"))

EDIT

After some extensive trial-and-error, it looks as though it was the download method used by install.packages that was to blame, so the solution was:

install.packages("dplyr", method = "libcurl")
like image 124
Allan Cameron Avatar answered Nov 02 '25 03:11

Allan Cameron


For me, using type="source" solved. i.e.

install.packages("dplyr", type="source")

Failing that, try downloading Rtools and double clicking on it to install it, close your R session and try again, it should succeed.

like image 28
stevec Avatar answered Nov 02 '25 02:11

stevec