简体   繁体   English

从github将dput()要点读入R

[英]Reading dput() gists from github into R

I am trying to read a gist containing a dput from Github: 我正在尝试阅读包含来自Github的dput的要点:

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

This generates: 这将产生:

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

Which I think is a Ruby error message rather than an R error. 我认为这是Ruby错误消息,而不是R错误。 Now consider this: 现在考虑一下:

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

This seems to work fine. 这似乎很好。 The former gist is rather large, 1.7mb. 前要点相当大,只有1.7mb。 Could this be why I can't read it from Github. 这可能就是为什么我无法从Github上阅读它的原因。 If not, why? 如果没有,为什么?

The gist that you created does not have a .R file in it, since pull_lists does not have an extension. 您创建的主旨中没有.R文件,因为pull_lists没有扩展名。 I forked your gist to this one and added the extension. 将您的要点分叉到此,并添加了扩展名。 Now it is possible to source the gist and save it to a value. 现在可以获取要点并将其保存为一个值。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM