googlesheets4-configuration: googlesheets4 configuration

googlesheets4-configurationR 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:

  • Put options(googlesheets4_quiet = TRUE) in a start-up file, such as .Rprofile, or in your R script

  • Use local_gs4_quiet() to silence googlesheets4 in a specific scope

  • Use with_gs4_quiet() to run a small bit of code silently

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:

  • Default Google user or, more precisely, email: see gargle::gargle_oauth_email()

  • Whether or where to cache OAuth tokens: see gargle::gargle_oauth_cache()

  • Whether to prefer "out-of-band" auth: see gargle::gargle_oob_default()

  • Application Default Credentials: see gargle::credentials_app_default()

Examples


# 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()


tidyverse/googlesheets4 documentation built on July 24, 2024, 1:40 a.m.