【问题标题】:Reading dput() gists from github into R将 dput() gists 从 github 读入 R
【发布时间】:2015-02-09 20:02:57
【问题描述】:

我正在尝试从 Github 阅读包含 dput 的要点:

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 读取它的原因吗?如果不是,为什么?

【问题讨论】:

  • 你看过devtools包中的source_gist()函数吗?为了清楚起见,您只需调用getURL 就会收到此错误?还是您在“数据”变量中获取数据?
  • @MrFlick:我尝试了source_gist("https://gist.github.com/aronlindberg/b6b934b39e3c3378c3b2"),它应该加载第二个适用于我的方法的要点。但是,使用 source_gist() 这似乎不起作用:Error: No R files found in gist

标签: ruby r reproducible-research


【解决方案1】:

您创建的 gist 中没有 .R 文件,因为 pull_lists 没有扩展名。我将your gist 分叉到this one 并添加了扩展名。现在可以获取 gist 并将其保存为一个值。

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

【讨论】:

    猜你喜欢
    • 2013-01-04
    • 2012-10-15
    • 1970-01-01
    • 2022-01-21
    • 2019-02-18
    相关资源
    最近更新 更多