2016-07-13 8 views
12

我试图使用source_gistdevtools包,但我遇到了一个错误:R:source_gist不工作​​

> library(devtools) 
> source_gist("524eade46135f6348140") 
Error in r_files[[which]] : invalid subscript type 'closure' 

感谢您的任何意见。

+0

它追踪到'devtools ::: find_gist'。尽管如此,还没有弄清楚这个问题。它看起来像局部变量'which'没有被识别。因为'which()'是一个基函数,所以在全局环境中执行'1 [[which]]'也是一样的错误。奇怪的。 –

+0

在'devtools ::: find_gist'中,if(length)(r_files)== 1'没有'if()'的条件,它在你的情况下是这样做的。我在控制台中运行了前两行'find_gist'来获得'r_files'。这对我来说看起来像一个bug。我会把它带到[devtools github页面](https://github.com/hadley/devtools)并提交一个问题。 –

回答

11

同意这是一个错误,我看你有submitted

临时的解决方法是指定的filename选项:

devtools::source_gist("524eade46135f6348140", filename = "ggplot_smooth_func.R") 
+1

此文件名解决方法也适用于我。 –

+1

这是[固定为2017/08/01](https://github.com/hadley/devtools/commit/c0121bff3e70f2891eaacf94ff14acfb4eaab37e),尽管您需要[开发版本](https://github.com/hadley/devtools),直到此修复程序被推送到CRAN。 – manimal