2015-02-09 50 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")