Rstudio can´t install any package. I´m a beginner. How to fix?

I am taking a Data Science course at Coursera using R. I installed version 4.0.2 of R for Windows 10 (x64), then R tools 40 and finally RStudio. Everything went well until I tried to install a package using the command: install.packages ("ggplot2")
I tried another command: install.packages (c ("devtools", "lme4"))
They all give the same error message, as shown below:

> install.packages(c("devtools", "lme4"))
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/src/contrib:
  unable to open the URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing packages into ‘C:/Users/ricardo.rfflj/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/src/contrib:
  unable to open the URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
  packages ‘devtools’, ‘lme4’ are not available (for R version 4.0.2)
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/bin/windows/contrib/3.4:
  unable to open the URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/PACKAGES'
Warning: unable to access index for repository https://cran.rstudio.com/src/contrib:
  unable to open the URL 'https://cran.rstudio.com/src/contrib/PACKAGES'

Has anyone been through this and know any solutions? Do I have to make any changes?

Welcome to the RStudio Community! Hope you enjoy your stay! :smiley:

Are you connected to the internet? It looks like R is unable to access the URL required to download these packages.

1 Like

Yes, I do. I accessed this forum from the same ultrabook in which it is installed.
The strange thing is that I can install from the R console, but not from RStudio.
Strange is also the error message stating that I did not install Rtools, but I have already installed and followed all instructions on the site.
It is also reporting that this package is not available for this version.
It could be a proxy problem, but I checked and the proxy is turned off.

It seems you haven configured your PATH correctly, I would recommend going over the configuration instructions again. Anyway, the current error message you are seeing is not related to Rtools not being found, this seems like a connectivity issue, R is not being able to connect to the CRAN repository you have selected, these are some things to try.

  • Choose a different CRAN repository, RStudios repository is a good choice (http://cran.rstudio.com/) or you could choose one that is geographically closer to you.
  • Disable secure download setting.
  • Check if your internet connection has traffic restrictions of some kind, like a firewall, proxy server, etc. This is usually the case when you are at work or school.
1 Like

I chose a different repository and managed to install a package through RStudio. Thank you

Is not being able to access the default repository something I should be concerned about?

In addition, after completing the installation of one of the packages, the following message appeared:
(as ‘lib’ is unspecified)

Do I have a problem with my library or is this message standard?

Only if having a restricted internet connectivity is a concern for you, although, that would be out of this forums scope.

You should be fine, it is just an informative message meaning that the default package library is being used since none has been explicitly specified.

1 Like

Thanks again. My problem is resolved

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.