R connect via proxy in Ubuntu

点点圈 提交于 2020-03-02 04:43:17

问题


I had installed RStudio 0.97.168 on Ubuntu 12.04. When I try to install gstat library I get the below error

install.packages("gstat", dependencies=TRUE)

Warning in install.packages :
  cannot open: HTTP status was '407 Proxy Authentication Required'
Warning in install.packages :
  cannot open: HTTP status was '407 Proxy Authentication Required'
Warning in install.packages :
  unable to access index for repository http://software.rc.fas.harvard.edu/mirrors/R/src/contrib
Warning in install.packages :
  package ‘gstat’ is not available (for R version 2.14.1)

I saw solutions like --intenet and setInternet(TRUE) which are only applicable for Windows OS.

Please provide help on changes I need to make to get behind my university proxy?


回答1:


You should be able to use the following in your R session:

Sys.setenv(http_proxy="http://user:pass@proxy.dom.com:8080/")

(Obviously, replace with your username, password, proxy server, and port.)

It's important that this is done before you first try to download anything--in other words, done preferably at the start of an R session. From the help page at ?download.file:

These environment variables must be set before the download code is first used: they cannot be altered later by calling Sys.setenv.

There are ways to make this change "permanent" too, but that might be inconvenient if you are working on a laptop or working with multiple internet connections, some of which requires access via a proxy server, and some which don't.




回答2:


You can try.

R.home()
find file Renviron.site
And add you proxy server address in R_HOME/etc/Renviron.site
http_proxy=http://<<your proxy server address>>/

This steps help me.


来源:https://stackoverflow.com/questions/13264761/r-connect-via-proxy-in-ubuntu

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!