SCDCE
SCDCE

Reputation: 1643

Reading in a Google Sheet to R

I don't think I'm understanding how to use the API in the googlesheets package. I'm wanting to read in this:

library(googlesheets)

url <- "https://docs.google.com/spreadsheets/d/e/2PACX-1vSrr9DRaC2fXzPdmOxLW-egSYtxmEp_RKoYGggt-zOKYXSx4RjPsM4EO19H7OJVX1esTtIoFvlKFWcn/pub#"

dat <- gs_read(url)

But I'm getting an error I don't understand:

Error in gs_read_csv(ss, ws = ws, ..., verbose = verbose) : 
  inherits(ss, "googlesheet") is not TRUE

Upvotes: 0

Views: 2327

Answers (1)

Noah Olsen
Noah Olsen

Reputation: 281

So gs_read actually takes a "spreadsheet" object that can be created with the gs_title() function. I would modify your code like the below.

library(googlesheets)
gs_auth()

name <- "name of google sheet"
spreadsheet_object <- gs_title(name)

dat <- gs_read(spreadsheet_object)

Let me know if that helps!

Upvotes: 1

Related Questions