2013-07-22 26 views
38

當您嘗試從GitHub的倉庫安裝一些包的R解決方案。如何install_github時,有一個代理

install_github('rWBclimate', 'ropensci') 

如果你有以下錯誤:

Installing github repo(s) rWBclimate/master from ropensci 
Downloading rWBclimate.zip from https://github.com/ropensci/rWBclimate/archive/master.zip 
Error in function (type, msg, asError = TRUE) : 
Could not resolve host: github.com; Host not found, try again 

顯示此錯誤的原因R是試圖通過代理訪問Intenet。

+0

歡迎的StackOverflow!雖然您極力鼓勵您提供您遇到並克服的問題的解決方案,但我們更希望您僅將問題框用於問題。您可以隨時使用提供的答案框回答自己的問題。有一些[規則](http://stackoverflow.com/help/self-answer)可以回答你自己的問題,你可能需要遵循。而你永遠不知道,有人可能會發布另一個你沒有想到的答案,讓你感到驚訝! – Enigmadan

+0

你應該真的把下面的答案標記爲接受... –

回答

54

SOLUTION

步驟1.安裝devtools包

if (!require("devtools")) install.packages("devtools") 
library(devtools) 

第2步:設置配置爲我們的代理(請更新您的信息代理)

library(httr) 
set_config(
    use_proxy(url="18.91.12.23", port=8080, username="user",password="password") 
) 
install_github('rWBclimate', 'ropensci') 
+5

'set_config'和'use_proxy'是'httr'庫的一部分,所以必須事先運行'require(httr)'。 – dmvianna

+0

謝謝。我添加了'.First < - function(){set_config(use_proxy(...))}; .First()',以及包依賴關係到'.Rprofile',以便在啓動時自動配置代理服務器。 – Mullefa

+7

如何查看代理目前的設置? – HattrickNZ

相關問題