2015-02-09 19 views
1

我試圖讀取包含從GitHub一個dput要旨:讀dput()從GitHub要旨成R

library(RCurl) 
data <- getURL("https://gist.githubusercontent.com/aronlindberg/848b8efef154d0e7fdb4/raw/5bf4bb864cc4c1db0f66da1be85515b4fa19bf6b/pull_lists") 
pull_lists <- dget(textConnection(data)) 

這產生:

Error: '\U' used without hex digits in character string starting ""@@ -1,7 +1,9 @@ 
module ActionDispatch 
    module Http 
    module URL 
-  # Returns the complete \U" 

我認爲這是一個Ruby錯誤消息而不是R錯誤。現在考慮這個:

data <- getURL("https://gist.githubusercontent.com/aronlindberg/b6b934b39e3c3378c3b2/raw/9b1efe9340c5b1c8acfdc90741260d1d554b2af0/data") 
pull_lists2 <- dget(textConnection(data)) 

這似乎工作正常。前者的要點相當大,1.7mb。難道這就是爲什麼我不能從Github上讀取它。如果不是,爲什麼?

+1

你看過'devtools'包中的'source_gist()'函數嗎?而且要明確一點,只有getURL調用纔會出現這個錯誤?或者你在「數據」變量中獲得數據? – MrFlick 2015-02-09 20:05:28

+0

@MrFlick:我試過'source_gist(「https://gist.github.com/aronlindberg/b6b934b39e3c3378c3b2」)'應該加載與我的方法一起工作的第二個要點。但是,對於'source_gist()',這似乎不起作用:'錯誤:在gist中找不到R文件 – histelheim 2015-02-09 20:31:06

回答

2

您創建的要點沒有.R文件,因爲pull_lists沒有擴展名。我分叉your gistthis one並添加了擴展名。現在可以找到要點並將其保存爲一個值。

library("devtools") 
pull_lists <- source_gist("a7b157cec3b9259fc5d1")