Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: "there is no package called ..." and trying to use install.packages to solve it

Tags:

package

r

The R studio I have in my university computer gives me an error when I try to download different packages, whereas when I'm with my laptop in the university server, I don't get this error. Because of this, I don't think that there is some kind of a proxy/server problem.

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

I also tried to download the package using R.exe program or download other packages and it gave me the same error.

After looking for a solution in the internet, I found this script:

install.packages('readr', dependencies = TRUE, repos='http://cran.rstudio.com/')

But it downloaded many different packages: picture

I would like to know the reason why RStudio gives me this error and what happened when I tried to download readr package using install.packages?

like image 253
M.P. Avatar asked Jan 30 '23 04:01

M.P.


2 Answers

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

This means that you don't have the package readr installed on your computer.

You then installed it with

install.packages('readr', dependencies = TRUE, repos='http://cran.rstudio.com/')

which is good. Most packages are not "stand-alone", they use other packages too, called dependencies. Because you used the default dependencies = TRUE, all the dependencies (and their dependencies) were also installed.

You can look at the CRAN page for readr: https://CRAN.R-project.org/package=readr to see its dependencies (anything in the "Depends" or "Imports" fields is required). And of course you need the dependencies of those dependencies, etc. Now that readr is installed along with its dependencies, you can run library(readr) to load it.

like image 66
Gregor Thomas Avatar answered Jan 31 '23 19:01

Gregor Thomas


Because you set dependencies = TRUE it installed all the dependencies for the package readr

Those several packages you listed are considered dependencies for readr.

You get that initial error when a package has yet to be downloaded.

like image 32
Omar Himada Avatar answered Jan 31 '23 19:01

Omar Himada