Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gs4_create

Create a new Sheet


Description

Creates an entirely new (spread)Sheet (or, in Excel-speak, workbook). Optionally, you can also provide names and/or data for the initial set of (work)sheets. Any initial data provided via sheets is styled as a table, as described in sheet_write().

Usage

gs4_create(name = gs4_random(), ..., sheets = NULL)

Arguments

name

The name of the new spreadsheet.

...

Optional spreadsheet properties that can be set through this API endpoint, such as locale and time zone.

sheets

Optional input for initializing (work)sheets. If unspecified, the Sheets API automatically creates an empty "Sheet1". You can provide a vector of sheet names, a data frame, or a (possibly named) list of data frames. See the examples.

Value

The input ss, as an instance of sheets_id

See Also

Wraps the spreadsheets.create endpoint:

There is an article on writing Sheets:

Other write functions: gs4_formula(), range_delete(), range_flood(), range_write(), sheet_append(), sheet_write()

Examples

if (gs4_has_token()) {
  gs4_create("gs4-create-demo-1")

  gs4_create("gs4-create-demo-2", locale = "en_CA")

  gs4_create(
    "gs4-create-demo-3",
    locale = "fr_FR",
    timeZone = "Europe/Paris"
  )

  gs4_create(
    "gs4-create-demo-4",
    sheets = c("alpha", "beta")
  )

  my_data <- data.frame(x = 1)
  gs4_create(
    "gs4-create-demo-5",
    sheets = my_data
  )

  gs4_create(
    "gs4-create-demo-6",
    sheets = list(iris = head(iris), mtcars = head(mtcars))
  )

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

googlesheets4

Access Google Sheets using the Sheets API V4

v0.3.0
MIT + file LICENSE
Authors
Jennifer Bryan [cre, aut] (<https://orcid.org/0000-0002-6983-2759>), RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.