Mamba
Mamba

Reputation: 1203

How to use require(googlesheets) properly?

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")

Upvotes: 7

Views: 192

Answers (1)

David Robinson
David Robinson

Reputation: 78610

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

Upvotes: 6

Related Questions