Changes the name of a (work)sheet.

sheet_rename(ss, sheet = NULL, new_name)

Arguments

ss

Something that identifies a Google Sheet:

  • its file id as a string or drive_id

  • a URL from which we can recover the id

  • a one-row dribble, which is how googledrive represents Drive files

  • an instance of googlesheets4_spreadsheet, which is what gs4_get() returns

Processed through as_sheets_id().

sheet

Sheet to rename, in the sense of "worksheet" or "tab". You can identify a sheet by name, with a string, or by position, with a number. Defaults to the first visible sheet.

new_name

New name of the sheet, as a string. This is required.

Value

The input ss, as an instance of sheets_id

See also

Examples

if (gs4_has_token()) {
  ss <- gs4_create(
    "sheet-rename-demo",
    sheets = list(cars = head(cars), chickwts = head(chickwts))
  )
  sheet_names(ss)

  ss %>%
    sheet_rename(1, new_name = "automobiles") %>%
    sheet_rename("chickwts", new_name = "poultry")

  # clean up
  gs4_find("sheet-rename-demo") %>%
    googledrive::drive_trash()
}
#>  Creating new Sheet: sheet-rename-demo.
#>  Renaming sheet cars to automobiles.
#>  Renaming sheet chickwts to poultry.
#> File trashed:
#>sheet-rename-demo <id: 1FlPxpbW_AOiULPBBRgxK0WD0fV37eZ2nht2L65iul74>