install.packages("devtools") fails - r

I'm new to installing packages and R,
It looks like my devtools library is missing.
I was trying to install swirl,
I got the following message :
> install.packages("swirl")
Installing package into ‘C:/Users/cory/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Warning: failed to download mirrors file (cannot open destfile 'C:\Users\cory\AppData\Local\Temp\RtmpuA5tgZ\filef6c6874433a', reason 'No such file or directory'); using local file 'C:/PROGRA~1/R/R-35~1.1/doc/CRAN_mirrors.csv'
Warning: unable to access index for repository https://cran.cnr.berkeley.edu/src/contrib:
cannot open destfile 'C:\Users\cory\AppData\Local\Temp\RtmpuA5tgZ\filef6c4b9547', reason 'No such file or directory'
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning messages:
1: package ‘swirl’ is not available (for R version 3.5.1)
2: In gzfile(file, mode) :
cannot open compressed file 'C:\Users\cory\AppData\Local\Temp\RtmpuA5tgZ/libloc_194_4cc5b48b.rds', probable reason 'No such file or directory'
I then tried the following :
> library(devtools)
Error in library(devtools) : there is no package called ‘devtools’
So I downloaded devtools in zip format and tried loading it
> getwd()
[1] "C:/Users/cory/Documents"
I downloaded the devtools zip in the same folder, and renamed it to devtoolz zip
I tried running the command again
> install.packages("devtools")
Installing package into ‘C:/Users/cory/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository http://cran.rstudio.com/src/contrib:
cannot open destfile 'C:\Users\cory\AppData\Local\Temp\RtmpuA5tgZ\filef6c77f36a9', reason 'No such file or directory'
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning messages:
1: package ‘devtools’ is not available (for R version 3.5.1)
2: In gzfile(file, mode) :
cannot open compressed file 'C:\Users\cory\AppData\Local\Temp\RtmpuA5tgZ/libloc_194_4cc5b48b.rds', probable reason 'No such file or directory'
What steps should I take to get the devtools installed?
Many thanks! :)

I found a way around this,
In case it helps someone else :
*In Rstudio, it tuns out it is possible to install a package without downloading locally and without pointing to an URL (which I also had tried). Because it is integrated with CRAN-mirrors, I was able to simply type devtools in the box and select it from the existing drop-down menu.
It proved more efficient than trying to manually import it through RGui.*

I had the same issue, I just closed my RStudio and opened it, and it worked.

Related

Problems installing R package heplots

I tried to install R package "heplots" in R 4.1.3 using Rstudio but I get the following error:
Warning in install.packages :
unable to access index for repository https://cran.rstudio.com/src/contrib:
cannot open destfile 'C:\Users\myuser\AppData\Local\Temp\RtmpiIlWmJ\file821048e42b13', reason 'No such file or directory'
Installing package into ‘C:/Users/myuser/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
unable to access index for repository https://cran.rstudio.com/src/contrib:
cannot open destfile 'C:\Users\myuser\AppData\Local\Temp\RtmpiIlWmJ\file8210644e40c6', reason 'No such file or directory'
Warning in install.packages :
package ‘heplots’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
Warning in install.packages :
unable to access index for repository https://cran.rstudio.com/bin/windows/contrib/4.1:
cannot open destfile 'C:\Users\myuser\AppData\Local\Temp\RtmpiIlWmJ\file8210db01a9c', reason 'No such file or directory'
This appeared when I used the install.packages function. If I download the .tar.gz file from CRAN and try to install it that way I get this message:
Installing package into ‘C:/Users/guill/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
ERROR: dependency 'car' is not available for package 'heplots'
* removing 'C:/Users/myuser/Documents/R/win-library/4.1/heplots'
Warning in install.packages :
installation of package ‘C:/Users/myuser/Downloads/heplots_1.3-9.tar.gz’ had non-zero exit status
So I thought that if I install "car" then it would work. The problem is that the same happens with car and a lot of new dependenies appear (also the imports need to be installed), and when I try to install those manually they also have their own dependencies that need installing. I surrendered after the fourth layer of dependencies. Anyone knows how it should be done or am I stuck on manual dependency hell?

Unable to access libraries in RStudio but not in R

I am facing a problem in RStudio when installing and using packages. I'm very very new to it so please bear with me while I describe it:
This is a new R and Rstudio installation in my PC, R version 4.1.2. For remote work due to life stuff. I usually run these same commands in my job computer with no problem (always in administrator mode).
However, when installing "readxl" to open an excel file:
> install.packages("readxl")
Installing package into ‘C:/Program Files/R/R-4.1.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/readxl_1.3.1.zip'
Content type 'application/zip' length 1717234 bytes (1.6 MB)
downloaded 1.6 MB
package ‘readxl’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘readxl’
Warning in install.packages :
problem copying C:\Program Files\R\R-4.1.2\00LOCK\readxl\libs\x64\readxl.dll to C:\Program Files\R\R-4.1.2\readxl\libs\x64\readxl.dll: Permission denied
Warning in install.packages :
restored ‘readxl’
The downloaded binary packages are in
C:\Users\Andrés RM\AppData\Local\Temp\Rtmp2RhFPr\downloaded_packages
I've read about deleting 00lockto avoid this problem but I can't find the file anywhere.
And when i check my libraries using libpath()
> .libPaths()
[1] "C:/Program Files/R/R-4.1.2" "C:/Program Files/R/R-4.1.2/library"
Then, if I want to load the library
> library(readxl)
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/Users/my_user/Documents": The system cannot find the path specified
It returns a path that I never specified in the first place and where I don't keep any other R library.
If i try to load an excel file:
R_meristem_measures <- read_excel("C:/Users/my_user/Desktop/R meristem measures.xlsx")
Error: Evaluation error: zip file 'C:\Users\my_user\Desktop\R meristem measures.xlsx' cannot be opened.
In addition: Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/Users/Andrés RM/Desktop/R meristem measures.xlsx": The system cannot find the path specified
After this, .libPaths()keeps returning the same results.
This happens with some other packages that I use daily (in my other computer) and the warning is the same.
However, I just tried to run this same code in native R (R x64 4.1.2) and it went perfect with no issues.
I am at a loss here. Among others I've tried sys.setenv(R_LIBS_USER)and also changing the same environment variables from the Control panel.R_LIBS="C:/R/library"also does not work.
At work I am using R 4.0 and libPaths()returns
.libPaths()
[1] "C:/Users/my_user/Documents/R/win-library/4.0" "C:/Program Files/R/R-4.0.2/library"
which is expected since my_user/etc is where i keep my packages.
Is this a problem with my computer or with something particular from RStudio? R itself works perfect but is a pain to use and I would like to use RStudio even if I can run my stuff in R console.
Thanks to everyone

How can I install readxl package for R?

I am trying to install readxl package for R.
The following is the RStudio output:
To learn more and/or disable this warning message see the "Use secure download method for HTTP" option in Tools -> Global Options -> Packages.
> library('readxl')
Error in library("readxl") : there is no package called ‘readxl’
> install.packages("readxl")
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/src/contrib:
cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Installing package into ‘C:/Users/Lenovo/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/src/contrib:
cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
package ‘readxl’ is not available (for R version 3.5.0)
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/3.5:
cannot open URL 'http://cran.rstudio.com/bin/windows/contrib/3.5/PACKAGES'
>
The following is the R's console output:
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> install.packages("readxl")
Installing package into ‘C:/Users/Lenovo/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Warning: failed to download mirrors file (cannot open URL 'https://cran.r-project.org/CRAN_mirrors.csv'); using local file 'C:/PROGRA~1/R/R-35~1.0/doc/CRAN_mirrors.csv'
Warning: unable to access index for repository https://cloud.r-project.org/src/contrib:
cannot open URL 'https://cloud.r-project.org/src/contrib/PACKAGES'
Warning: unable to access index for repository https://cloud.r-project.org/bin/windows/contrib/3.5:
cannot open URL 'https://cloud.r-project.org/bin/windows/contrib/3.5/PACKAGES'
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
InternetOpenUrl failed: ''
2: package ‘readxl’ is not available (for R version 3.5.0)
>
How can I solve this issue?
The error messages definitely seem to be telling you, that R cannot connect to download the packages. Here are some thoughts:
Does your user profile have administrative privileges? I am not a huge Windows user, but your are technically trying to add software, which sometimes requires escalated privileges. Maybe trying running R as Admin in windows, for this one issue to see if that is the problem. (Doesn't seem very likely.)
If it is a firewall issue you could try to add an exception to your firewall settings for R and/or Cran repositories.
Have your tried to account for dependent packages? install.packages("readxl", dependencies = TRUE) (This can cause its own bag of issues as well, so consider yourself forewarned.)
Can you download any other packages? As you can access the internet to make stack posts, are asking a fairly entry level question, and the URL's are valid so there may be a configuration issue with your installation of R. If all else fails, you may wish to uninstall/reinstall R on your system (and Maybe R studio while you are at it) as that may help to repair something if it is damaged. Use the file checksums, the are there for a reason.

Failed to download mirror file in R programing language (version 3.5)

I facing problem to install any package in R programing language.
install.packages("nnet")
after hitting enter to run the above code, getting the following:
Installing package into ‘C:/Users/Acer/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Warning: failed to download mirrors file (cannot open URL 'https://cran.r-project.org/CRAN_mirrors.csv'); using local file 'C:/PROGRA~1/R/R-34~1.2/doc/CRAN_mirrors.csv'
Warning: unable to access index for repository
https://ftp.iitm.ac.in/cran/src/contrib: cannot open URL
'https://ftp.iitm.ac.in/cran/src/contrib/PACKAGES' Warning: unable to
access index for repository
https://ftp.iitm.ac.in/cran/bin/windows/contrib/3.4: cannot open URL
'https://ftp.iitm.ac.in/cran/bin/windows/contrib/3.4/PACKAGES' Warning
messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
InternetOpenUrl failed: 'The connection with the server was reset'
2: package ‘nnet’ is not available (for R version 3.4.2)
I am not able to fix the problem. Can anyone help me on this issue, please?

R "Userfriendlyscience" Package

I am having trouble loading the userfriendlyscience package in R. I am able to load other packages without a problem but this one is giving me the error:
Warning in install.packages : error 1 in extracting from zip file
Warning in install.packages : cannot open compressed file
'BH/DESCRIPTION', probable reason 'No such file or directory' Error in
install.packages : cannot open the connection
Not sure how to resolve the issue.

Resources