如何正确使用require(googlesheets)?

时间:2015-04-27 15:04:48

标签: r r-googlesheets

我最近通过

下载了googlesheets
devtools::install_github("jennybc/googlesheets")

并遇到一些困难。运行时提到的脚本 https://github.com/jennybc/googlesheets我总是得到:

Error: could not find function "%>%"

我该如何解决这个问题?

可重复的例子:

下载:

devtools::install_github("jennybc/googlesheets")
require(googlesheets)

数据:

gap_key <- "1HT5B8SgkKqHdqHJmn5xiuaC04Ngb7dG9Tv94004vezA"
copy_ss(key = gap_key, to = "Gapminder")
gap <- register_ss("Gapminder")

发生错误:

oceania_csv <- gap %>% get_via_csv(ws = "Oceania")

1 个答案:

答案 0 :(得分:6)

首先加载dplyr包,它提供%>%运算符。在您链接到的自述文件中注明heresuppressMessages是可选的):

  

googlesheets旨在与%&gt;%管道运算符一起使用,并且在较小程度上与dplyr的数据争用心态一起使用。这里的例子都使用了这两个例子,但是我们很快就会开发出一个小插图来展示普通香草的用法.Googlesheets在内部使用dplyr,但不要求用户这样做。

library("googlesheets")
suppressMessages(library("dplyr"))

您可以使用

安装dplyr
install.packages("dplyr")

有关管道运算符(%>%)的更多信息,请参阅here