7

I recently downloaded googlesheets via

devtools::install_github("jennybc/googlesheets")

and experience some difficulties. When running the script as mentioned in https://github.com/jennybc/googlesheets I get always:

Error: could not find function "%>%"

How can I solve that problem?

Reproducible example:

Download:

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

Data:

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

Error occurs:

oceania_csv <- gap %>% get_via_csv(ws = "Oceania")
Rentrop
  • 20,979
  • 10
  • 72
  • 100
Mamba
  • 1,183
  • 2
  • 13
  • 33

1 Answers1

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 (%>%).

David Robinson
  • 77,383
  • 16
  • 167
  • 187
  • 6
    Strictly speaking the `magrittr` package provides the `%>%` operator, but `dplyr` imports and re-exports it, making it available to users. You can just `require(magrittr)` and the pipe operator should work. – Spacedman Apr 27 '15 at 15:14