googlesheets4-configuration {googlesheets4}R Documentation

googlesheets4 configuration

Description

Some aspects of googlesheets4 behaviour can be controlled via an option.

Usage

local_gs4_quiet(env = parent.frame())

with_gs4_quiet(code)

Arguments

env

The environment to use for scoping

code

Code to execute quietly

Messages

The googlesheets4_quiet option can be used to suppress messages from googlesheets4. By default, googlesheets4 always messages, i.e. it is not quiet.

Set googlesheets4_quiet to TRUE to suppress messages, by one of these means, in order of decreasing scope:

local_gs4_quiet() and with_gs4_quiet() follow the conventions of the the withr package (https://withr.r-lib.org).

Auth

Read about googlesheets4's main auth function, gs4_auth(). It is powered by the gargle package, which consults several options:

Examples

if (gs4_has_token()) {
  # message: "Creating new Sheet ..."
  (ss <- gs4_create("gs4-quiet-demo", sheets = "alpha"))

  # message: "Editing ..., Writing ..."
  range_write(ss, data = data.frame(x = 1, y = "a"))

  # suppress messages for a small amount of code
  with_gs4_quiet(
    ss %>% sheet_append(data.frame(x = 2, y = "b"))
  )

  # message: "Writing ..., Appending ..."
  ss %>% sheet_append(data.frame(x = 3, y = "c"))

  # suppress messages until end of current scope
  local_gs4_quiet()
  ss %>% sheet_append(data.frame(x = 4, y = "d"))

  # see that all the data was, in fact, written
  read_sheet(ss)

  # clean up
  gs4_find("gs4-quiet-demo") %>%
    googledrive::drive_trash()
}

[Package googlesheets4 version 1.0.0 Index]