RStudio package Installation - r

I had posted a few days earlier about issues in installing packages in RStudio here - RStudio Package installation error. However, my question was marked as duplicate, assuming that the solution posted in the comments is actually the best solution.
Although I have the exact same problem as already mentioned, that solution posted by Ian doesn't help. In fact I get a new kind of error. Please see below:
Warning in install.packages :
unable to connect to 'cran.rstudio.com' on port 80.
Warning in install.packages :
unable to connect to 'cran.rstudio.com' on port 80.
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/3.1
Warning in install.packages :
unable to connect to 'www.stats.ox.ac.uk' on port 80.
Warning in install.packages :
unable to connect to 'www.stats.ox.ac.uk' on port 80.
Warning in install.packages :
unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.1
Installing package into ‘C:/Users/avi/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)

It looks like a connection issue, rather than an installation issue. If you work in an organisation - such as a university - and are behind their firewall it could, for example, be a proxy issue.
Two workarounds (as I'm not a network specialist):
If you can move your data to a personal computer (i.e. no encryption/data protection issues) try installing R and RStudio on another computer and see if you can install packages (preferably using a different internet connection, e.g. from your home).
You can install packages from source, so you could download the package and install without needing a connection in RStudio. See, for example, this post: How do I install an R package from source?
If these do not help, additional information that would be helpful for others would be a list of the package(S) you're trying to install, where you're trying to connect from and if that has a firewall, and how you're trying to install packages (i.e. what commands are you typing). Additionally, your organisation/institution computer services might be able to help.
Good luck.

I have seen this problem on corporate networks where this access method is blocked. One solution is to try RStudio as it uses a different method to install packages and may work for your case.

Do these steps :
Tools -> Global Options -> Packages and uncheck the "Use Internet Explorer library/proxy for HTTP".
Restart R ,and it should work

I've had a similar error. That's what I did to fix it:
Tried to install RODBC -> install.packages("RODBC")
Got a failed to connect to 'cran.r-project.org' on port 80." error message
Used the setInternet2(TRUE) command to force it to use my Internet Explorer proxy config
You can check if the command has worked by typing setInternet2(NA). If it returns [1] TRUE, it's working
In some cases, that should be enough (just run the install.packages again). For me, it wasn't (my proxy server requires a password)
The error that I got after trying to run the install.packages was 407 Proxy Authentication Required
To get rid of this last error message, I had to manually configure my proxy credentials. For that, you will need to run Sys.setenv( "http_proxy"="http://<username>:<password>#<proxy-host>:<port>" ) a real life code should look like this one Sys.setenv( "http_proxy"="http://user:password#192.127.100.32:80" )
After that, I tried to install my packages again end it worked perfectly.
If you can't make it work even after that, you can still download the package using your browser and install it locally.
install.packages( file.choose(), repos=NULL )
The file.choose() will prompt you for the name of the downloaded package file.
This link helped me A LOT with this soluction.

Related

Unable to install R packages for R 4.1

I am unable to install any R packages today. The issue did not happen until last week (the last time I use the command). My laptop system is a Windows 10, and I am not using any local network/proxy/work Internet, so pretty sure it is not the proxy server or firewall issue. I updated my R, restart the program and the computer, no help.
Here is the error message.
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'
Here are the methods I have tried from the Internet but did NOT work:
Update the CRAN Repository for installing packages
Uncheck the "Use secure download method for HTTP" and "Use Internet Explorer library/proxy for HTTP" options
Run R as administrator
Change the library to install packages
Use the install.packages('package_name', dependencies=TRUE, repos='http://cran.rstudio.com/')
Again, I am pretty sure there is no firewall/proxy issue, as I never had the problem until last week, using the same Internet and the same device. Does anyone have ideas? Thanks in advance for the help!
The issue was eventually solved by options(download.file.method="libcurl").
Following another suggested answer, I tried options(repos = "http://cran.rstudio.com/") but got the below message:
Warning message:
In download.file(mirrors_csv_url, destfile = mirrors_csv, quiet = TRUE) :
InternetOpenUrl failed: 'ìÂs°þ$'
Then the answer to this question did the trick.

there is no package called 'gridExtra' [duplicate]

This question already has answers here:
How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?
(18 answers)
Closed 6 years ago.
I am unable to install packages through latest version of RStudio and R Version.3.1.1. Kindly help. I got the error as mentioned below:
Example:
Warning in install.packages :
InternetOpenUrl failed: ''
Warning in install.packages :
InternetOpenUrl failed: ''
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/3.1
Installing package into ‘C:/Users/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
InternetOpenUrl failed: ''
Warning in install.packages :
InternetOpenUrl failed: ''
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/3.1
Warning in install.packages :
package ‘reshape’ is not available (for R version 3.1.1)
Not 100% certain that you have the same problem, but I found out the hard way that my job blocks each mirror site option that was offered and I was getting errors like this:
Installing package into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Error in download.file(url, destfile = f, quiet = TRUE) :
unsupported URL scheme
Warning: unable to access index for repository https://rweb.crmda.ku.edu/cran/src/contrib
Warning message:
package ‘ggplot2’ is not available (for R version 3.2.2)
Workaround (I am using CentOS)...
install.packages('package_name', dependencies=TRUE, repos='http://cran.rstudio.com/')
I hope this saves someone hours of frustration.
I think this is the "set it and forget it" solution:
options(repos='http://cran.rstudio.com/')
Note that this isn't https. I was on a Linux machine, ssh'ing in. If I used https, it didn't work.
As #Pascal said, it is likely that you encounter problem with the firewall or/and proxy issue.
As a first step, go through FAQ on the CRAN web page. After that, try to flag R with --internet2.
Sometimes it could be useful to check global options in R studio and uncheck "Use Internet Explorer library/proxy for HTTP".
Tools -> Global Options -> Packages and unchecking the "Use Internet Explorer library/proxy for HTTP" option.
Hope this helps.
Based on answers from the community, there appear to be several ways that might solve this:
From the official FAQ and support forums and this answer, you may have have a firewall or proxy issue that is blocking RStudio from connecting to the internet:
Disable any firewalls
Tools -> Global Options -> Packages and unchecking the "Use Internet Explorer library/proxy for HTTP" option and restart R (#1, #2, #3)
Flag R with --internet2
On CentOS it was suggested to try the following: install.packages('package_name', dependencies=TRUE, repos='http://cran.rstudio.com/')
Several answers suggest using an alternate mirror (#1, #2, #3):
Preferences > General > Default working directory > Browse and switch your mirror from local/global (whichever is unchecked)
On Windows you can start the application with http_proxy=http://host:port/:
"C:\Program Files\RStudio\bin\rstudio.exe" http_proxy=http://host:port/
Shut down and restart. Needed after many of the above operations, and suggested standalone.
My solution that worked was to open R studio options and select global miror (the field was empty before) and the error went away.
Please check the following to be able to install new packages:
1- In Tools -> Global Options -> Packages, uncheck the "Use Internet Explorer library/proxy for HTTP" option,
2- In Tools -> Global Options -> Packages, change the CRAN mirror to "0- Cloud - Rstudio, automatic redirection to servers worldwide"
3- Restart Rstudio.
4- Have fun!
If you are on Windows, try this:
"C:\Program Files\RStudio\bin\rstudio.exe" http_proxy=http://host:port/
Most of the time #cer solution works but if in case its not working then try installing it in base R (NOT in R studio). As R studio runs base R executable in background so new package will be available in R studio as well. [my experience in macOS]
What worked for me:
Preferences-General-Default working directory-Browse Switch from global to local mirror
Working on a Mac. 10.10.3

R Package installation Issue

I'm not able to install any packages in R. I tried in all versions of R starting from 3.2.2 till 3.2.4(revised), but I get the same error. It seems like a proxy issue to me as I'm connected to my college firewall. I was able to install the packages when I'm connected to my home network. Can you please guide me to resolve this issue.?
Here are the error messages
> chooseCRANmirror()
Error in download.file(url, destfile = f, quiet = TRUE) :
cannot open URL 'https://cran.r-project.org/CRAN_mirrors.csv'
In addition: Warning message:
In download.file(url, destfile = f, quiet = TRUE) :
InternetOpenUrl failed: 'The server name or address could not be resolved'
> install.packages("ggplot2")
Installing package into ‘C:/Users/HP/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository https://cran.rstudio.com/src/contrib
Warning: unable to access index for repository
Warning: unable to access index for repository
Warning: unable to access index for repository
Warning message:
package ‘ggplot2’ is not available (for R version 3.2.2)
This is the same problem I was also facing while installing any packages. The main reason what I think is that your R session can't connect to the files path on Cran server.
What I did was just manually go to the Cran website and download the windows release for that particular package. Now unzip the files and manually paste the folder into your library folder of R.
The library folder path will be something like this:
C:\Program Files\R\R-3.2.3\library
Now go to your R console and load it with library(package name).
You can now use your package.
Simply use HTTP mirror instead of HTTPS ones.
To change mirror go to "Packages menu" -> "Set CRAN mirror" -> "(HTTP mirrors)" -> select any
Thanks for your valuable feedback guys. The solution to this problem drove me crazy. I have set my proxy settings according to my college network in MOZILLA, however, I have not set the same for IE. I guess, R downloads the packages based on IE settings, which was not configured. After setting the proxy to connect to the internet, I was able to download the packages without any issues.
Figured this out after trying all your solutions, but at last it was this silly thing that worked.
Thanks for all your time and suggestions.
you can reset and restore your internet connection (for windows and your default explorer),The problem will be solved.
To fix:
Uncheck the 'use secure download method' checkbox in Rstudio global options.
Restart internet then restart Rstudio
utils:::menuInstallPkgs()
--- Please select a CRAN mirror for use in this session ---
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'
Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) :
no packages were specified

Unable to install packages in latest version of RStudio and R Version.3.1.1 [duplicate]

This question already has answers here:
How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?
(18 answers)
Closed 6 years ago.
I am unable to install packages through latest version of RStudio and R Version.3.1.1. Kindly help. I got the error as mentioned below:
Example:
Warning in install.packages :
InternetOpenUrl failed: ''
Warning in install.packages :
InternetOpenUrl failed: ''
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/3.1
Installing package into ‘C:/Users/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
InternetOpenUrl failed: ''
Warning in install.packages :
InternetOpenUrl failed: ''
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/3.1
Warning in install.packages :
package ‘reshape’ is not available (for R version 3.1.1)
Not 100% certain that you have the same problem, but I found out the hard way that my job blocks each mirror site option that was offered and I was getting errors like this:
Installing package into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Error in download.file(url, destfile = f, quiet = TRUE) :
unsupported URL scheme
Warning: unable to access index for repository https://rweb.crmda.ku.edu/cran/src/contrib
Warning message:
package ‘ggplot2’ is not available (for R version 3.2.2)
Workaround (I am using CentOS)...
install.packages('package_name', dependencies=TRUE, repos='http://cran.rstudio.com/')
I hope this saves someone hours of frustration.
I think this is the "set it and forget it" solution:
options(repos='http://cran.rstudio.com/')
Note that this isn't https. I was on a Linux machine, ssh'ing in. If I used https, it didn't work.
As #Pascal said, it is likely that you encounter problem with the firewall or/and proxy issue.
As a first step, go through FAQ on the CRAN web page. After that, try to flag R with --internet2.
Sometimes it could be useful to check global options in R studio and uncheck "Use Internet Explorer library/proxy for HTTP".
Tools -> Global Options -> Packages and unchecking the "Use Internet Explorer library/proxy for HTTP" option.
Hope this helps.
Based on answers from the community, there appear to be several ways that might solve this:
From the official FAQ and support forums and this answer, you may have have a firewall or proxy issue that is blocking RStudio from connecting to the internet:
Disable any firewalls
Tools -> Global Options -> Packages and unchecking the "Use Internet Explorer library/proxy for HTTP" option and restart R (#1, #2, #3)
Flag R with --internet2
On CentOS it was suggested to try the following: install.packages('package_name', dependencies=TRUE, repos='http://cran.rstudio.com/')
Several answers suggest using an alternate mirror (#1, #2, #3):
Preferences > General > Default working directory > Browse and switch your mirror from local/global (whichever is unchecked)
On Windows you can start the application with http_proxy=http://host:port/:
"C:\Program Files\RStudio\bin\rstudio.exe" http_proxy=http://host:port/
Shut down and restart. Needed after many of the above operations, and suggested standalone.
My solution that worked was to open R studio options and select global miror (the field was empty before) and the error went away.
Please check the following to be able to install new packages:
1- In Tools -> Global Options -> Packages, uncheck the "Use Internet Explorer library/proxy for HTTP" option,
2- In Tools -> Global Options -> Packages, change the CRAN mirror to "0- Cloud - Rstudio, automatic redirection to servers worldwide"
3- Restart Rstudio.
4- Have fun!
If you are on Windows, try this:
"C:\Program Files\RStudio\bin\rstudio.exe" http_proxy=http://host:port/
Most of the time #cer solution works but if in case its not working then try installing it in base R (NOT in R studio). As R studio runs base R executable in background so new package will be available in R studio as well. [my experience in macOS]
What worked for me:
Preferences-General-Default working directory-Browse Switch from global to local mirror
Working on a Mac. 10.10.3

I am unable to use install.packages with the pkgs parameter to install a package from a local file (Win8.1, R3.10)

I am trying to install the rClr package. The instructions for this are to copy the package file onto the local computer and use install.packages(pkgs = "c:/.../rClr_0.5-2.zip"). I have a laptop, a server and a desktop. The laptop and the desktop are Windows 8.1, the server Windows 2012. All run R 3.1.0. The desktop installs rClr without a problem. The other two return the warning (error) message:
package ‘c:/.../rClr_0.5-2.zip’ is not available (for R version 3.1.0).
I've tried all obvious things. The error is pretty generic, it is given whenever install.packages can't find a file. The package is compatible with R 3.1.0, as evidenced by the fact it installs on my desktop. I've check for silly mistakes. I've tried moving the file to simpler directory structures (in case install.packages had a problem with spaces or special characters), I've given it maximum file permissions, tried playing around a few other things, but nothing makes a difference. I also tried replacing the local reference with a reference to the http link, and tried download another random package from CRAN to see if that would install, and both gave the same error message. I can't think of anything different in the environment of the laptop and the desktop. install.packages does work when installing the standard packages from CRAN.
Am I missing something obvious? Is there any known issue with install.packages (I thought maybe security but couldn't find anything on internet)? Are their ways to force an installation? Can anyone recommend something else to try?
Thanks.

Resources