R: Cannot use 0-cloud to install.packages

2019-05-05 04:17发布

问题:

When I try to install packages from 0-cloud it doesn't work

> install.packages("lfactors")
--- Please select a CRAN mirror for use in this session ---

then I select 0-cloud from the list of repositories. and R returns

Warning: unable to access index for repository https://cran.rstudio.com/src/contrib
Warning: unable to access index for repository https://cran.rstudio.com/bin/windows/contrib/3.2
Warning message:
package ‘lfactors’ is not available (for R version 3.2.1) 

But, when I run this code and select another repository it does work.

I tried turning off my proxy server, and visiting the site with the proxy server on and I can visit it in the browser with no issue.

Any ideas?

Edit: based on a comment, I ran this

capabilities()["libcurl"]
libcurl 
   TRUE

So I think it's not that.

回答1:

Your R binary may have been built without curl support, and you cannot access https servers. See what this returns:

R> capabilities()["libcurl"]
libcurl 
   TRUE 
R> 

In case this is FALSE for you, do two things:

  1. Change options("repos") to use http instead of https.

  2. Rebuild R to have libcurl support.

I do this in Rprofile.site:

## Example of Rprofile.site
local({
    r <- getOption("repos")
    r["CRAN"] <- "http://cran.rstudio.com"    ## not https for you
    options(repos = r)
})

Edit: Another possibility, particularly on Windows, is that the internet2 dll has to be activate, so running setInternet2(TRUE) once should help.



标签: r rstudio