7

我最近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")
4

1 回答 1

6

Load the dplyr package first, which provides the %>% operator. This is noted here in the README you link to (suppressMessages is optional):

googlesheets is designed for use with the %>% pipe operator and, to a lesser extent, the data-wrangling mentality of dplyr. The examples here use both, but we'll soon develop a vignette that shows usage with plain vanilla R. googlesheets uses dplyr internally but does not require the user to do so.

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

You can install dplyr with

install.packages("dplyr")

See here for more about the pipe operator (%>%).

于 2015-04-27T15:06:51.487 回答