How to install packages in R when using Mac OS BigSur - r

Ever since I updated to Mac BigSur, I have not been able to work with R, I am trying to install rstan/rstanarm, but I will never get there if I cannot install anything, do you have any suggestions in fixing the issue below, or alternatively suggesting a different way to install packages. Thanks!
Christian
R version 4.0.5 (2021-03-31) -- "Shake and Throw"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
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.
[R.app GUI 1.74 (7950) x86_64-apple-darwin17.0]
[History restored from /Users/christianbasile/.Rapp.history]
> install.packages("rstan")
--- 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 '/Library/Frameworks/R.framework/Resources/doc/CRAN_mirrors.csv'
Error in if (res > nrow(m)) { : argument is of length zero
In addition: Warning message:
In download.file(url, destfile = f, quiet = TRUE) :
URL 'https://cran.r-project.org/CRAN_mirrors.csv': status was 'Couldn't connect to server'
> install.packages("rstan")
--- 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 '/Library/Frameworks/R.framework/Resources/doc/CRAN_mirrors.csv'
Warning: unable to access index for repository https://cran.case.edu/src/contrib:
cannot open URL 'https://cran.case.edu/src/contrib/PACKAGES'
Warning: unable to access index for repository https://cran.case.edu/bin/macosx/contrib/4.0:
cannot open URL 'https://cran.case.edu/bin/macosx/contrib/4.0/PACKAGES'
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
URL 'https://cran.r-project.org/CRAN_mirrors.csv': status was 'Couldn't connect to server'
2: package ‘rstan’ 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
> install.packages("tidyverse", repos = "http://cran.rstudio.com")
Warning: unable to access index for repository http://cran.rstudio.com/src/contrib:
Line starting '<!DOCTYPE HTML PUBLI ...' is malformed!
Warning: unable to access index for repository http://cran.rstudio.com/bin/macosx/contrib/4.0:
Line starting '<!DOCTYPE HTML PUBLI ...' is malformed!
Warning message:
package ‘tidyverse’ 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
> usethis::edit_r_profile()
Error in loadNamespace(name) : there is no package called ‘usethis’
> install.packages("tidyverse", repos = "http://cran.rstudio.com")
Warning: unable to access index for repository http://cran.rstudio.com/src/contrib:
Line starting '<!DOCTYPE HTML PUBLI ...' is malformed!
Warning: unable to access index for repository http://cran.rstudio.com/bin/macosx/contrib/4.0:
Line starting '<!DOCTYPE HTML PUBLI ...' is malformed!
Warning message:
package ‘tidyverse’ 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
> R.home()
[1] "/Library/Frameworks/R.framework/Resources"
> local({
+ r = getOption("repos")
+ r["CRAN"] = "https://cran.rstudio.com/"
+ options(repos = r)
+ })
> install.packages("tidyverse", repos = "http://cran.rstudio.com")
Warning: unable to access index for repository http://cran.rstudio.com/src/contrib:
Line starting '<!DOCTYPE HTML PUBLI ...' is malformed!
Warning: unable to access index for repository http://cran.rstudio.com/bin/macosx/contrib/4.0:
Line starting '<!DOCTYPE HTML PUBLI ...' is malformed!
Warning message:
package ‘tidyverse’ 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
> install.packages("dplyr", method = "libcurl")
Warning: unable to access index for repository https://cran.rstudio.com/src/contrib:
cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
Warning: unable to access index for repository https://cran.rstudio.com/bin/macosx/contrib/4.0:
cannot open URL 'https://cran.rstudio.com/bin/macosx/contrib/4.0/PACKAGES'
Warning message:
package ‘dplyr’ 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
>
Do you have any suggestions? I have been installing different versions of R, but same outcome. I know it may be something with the Rstart files, but I am unsure how to fix it. I am relatively new working with R. I will appreciate the help!!
Christian

Related

error message while installing R Markdown on R version 4.0.1 on Windows

I am new to R and trying to install R Markdown on RStudio but it keeps giving me error messages eg
Warning in install.packages :
package ‘(tools)’ is not available (for R version 4.0.1)
Warning in install.packages :
unable to access index for repository https://cran.rstudio.com/bin/windows/contrib/4.0:
cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/PACKAGES'
Are you sure you have internet? try install.packages("Rmarkdown", dep = TRUE) you may also need to install latex for your system

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?

Issue in installation of mxnet package in R

mxnet package is not installing in r (on windows 10) when I follow the steps given in its documentation.
install.packages("drat", repos="https://cran.rstudio.com")
drat:::addRepo("dmlc")
install.packages("mxnet")
It gives the following result
Installing package into ‘C:/Users/Ashish/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified) Warning in install.packages : cannot open
URL 'http://dmlc.github.io/drat/bin/windows/contrib/3.3/PACKAGES.gz':
HTTP status was '404 Not Found' Warning in install.packages : cannot
open URL
'http://dmlc.github.io/drat/bin/windows/contrib/3.3/PACKAGES': HTTP
status was '404 Not Found' Warning in install.packages : unable to
access index for repository
http://dmlc.github.io/drat/bin/windows/contrib/3.3: cannot open URL
'http://dmlc.github.io/drat/bin/windows/contrib/3.3/PACKAGES' Package
which is only available in source form, and may need compilation of
C/C++/Fortran: ‘mxnet’ Do you want to attempt to install these from
sources? y/n: y installing the source package ‘mxnet’
trying URL 'http://dmlc.github.io/drat/src/contrib/mxnet_0.5.tar.gz'
Warning in install.packages : cannot open URL
'http://dmlc.github.io/drat/src/contrib/mxnet_0.5.tar.gz': HTTP status
was '404 Not Found' Error in download.file(url, destfile, method, mode
= "wb", ...) : cannot open URL 'http://dmlc.github.io/drat/src/contrib/mxnet_0.5.tar.gz' Warning in
install.packages : download of package ‘mxnet’ failed
Kindly help me resolve this issue. I'm using R version 3.3.0. Is there any other way of installing it in R?
I was able to install it successfully by first downloading its zip file from the following link
https://github.com/dmlc/drat/tree/gh-pages/bin/windows/contrib/3.2
and then installing it using RStudio.
I hope this answer will help anyone else facing the same problem.
I had the same issue and was able to resolve it by following the instructions on this page and choosing the correct OS, Language and CPU/GPU options:
http://mxnet.io/get_started/install.html
The only thing that worked for me was to download the mxnet.zip file to a folder, (set it as working directory) and type:
install.packages("mxnet.zip", repos=NULL, type="win.binary")
You can try using different repo in repos.
Otherwise you can download the drat package along with dependencies and install manually.
Check if these URLs are accessible from your machine or not.
Following links will be helpful for you:
http://mxnet-bing.readthedocs.io/en/latest/build.html#r-package-installation
https://github.com/dmlc/mxnet/issues/1085
The more up-to-date Installation Guide is currently located here:
http://mxnet.io/get_started/setup.html#installing-mxnet
I found the paragraph about the installation of the R-package on Windows to be very well written.
By the way, the install.packages("mxnet") command installs a very long tool chain, so it might happen that a package is currently not indexed correctly in the dmlc-repo (i.e. because it was just updated to a newer version on CRAN): Error: package <pkgname> is not available for R version 3.3.1 So you might want to install the "offending" package from the CRAN (or download the sourcecode and use something like install.packages(file.choose(), repos = NULL, type = "source")), then continue with another call to install.packages("mxnet").
try these commands to install mxnet package:--
cran <- getOption("repos")
cran["dmlc"] <- "https://s3-us-west-2.amazonaws.com/apache-mxnet/R/CRAN/"
options(repos = cran)
install.packages("mxnet")

unable to install packages in R on ubuntu 12.04

I have R installed on my ubuntu 12.04 laptop, I tried to install devtools, slidify and a couple of other packages
The following error message is what I see for ANY package (here shown for slidify) - When I am asked to select a mirror I have picked a couple -
Any help will be very much appreciated. Thanks !! Farrukh
install.packages("slidify") Installing package into
‘/home/azfarl/R/x86_64-pc-linux-gnu-library/3.2’ (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 message: package ‘slidify’ is not available (for R
version 3.2.4 Revised)

Resources