Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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")
like image 704
Mamba Avatar asked Apr 27 '15 15:04

Mamba


People also ask

How do I create Google Sheets step by step?

There are 3 ways to create a new spreadsheet in Google Sheets: Click the red "NEW" button on your your Google Drive dashboard and select "Google Sheets" Open the menu from within a spreadsheet and select "File > New Spreadsheet" Click "Blank" or select a template on the Google Sheets homepage.


1 Answers

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

like image 80
David Robinson Avatar answered Oct 20 '22 05:10

David Robinson