Changes the name of a (work)sheet.
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 filesan instance of
googlesheets4_spreadsheet
, which is whatgs4_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
Makes an UpdateSheetPropertiesRequest
:
Other worksheet functions:
sheet_add()
,
sheet_append()
,
sheet_copy()
,
sheet_delete()
,
sheet_properties()
,
sheet_relocate()
,
sheet_resize()
,
sheet_write()
Examples
ss <- gs4_create(
"sheet-rename-demo",
sheets = list(cars = head(cars), chickwts = head(chickwts))
)
#> ✔ Creating new Sheet: sheet-rename-demo.
sheet_names(ss)
#> ✖ Request 1 failed [429: RESOURCE_EXHAUSTED, per user quota].
#> ℹ Will retry in 61.4s.
#> ⠙ Retry happens in 1m
#> ⠹ Retry happens in 1m
#> ⠸ Retry happens in 1m
#> ⠼ Retry happens in 1m
#> ⠴ Retry happens in 50s
#> ⠦ Retry happens in 47s
#> ⠧ Retry happens in 44s
#> ⠇ Retry happens in 41s
#> ⠏ Retry happens in 38s
#> ⠋ Retry happens in 35s
#> ⠙ Retry happens in 32s
#> ⠹ Retry happens in 29s
#> ⠸ Retry happens in 26s
#> ⠼ Retry happens in 23s
#> ⠴ Retry happens in 20s
#> ⠦ Retry happens in 17s
#> ⠧ Retry happens in 14s
#> ⠇ Retry happens in 11s
#> ⠏ Retry happens in 8s
#> ⠋ Retry happens in 5s
#> ⠙ Retry happens in 2s
#> ✖ Request 2 failed [429: RESOURCE_EXHAUSTED, per user quota].
#> ⠙ Retry happens in 2s
#> ℹ Will retry in 1.4s.
#> ⠙ Retry happens in 2s
#> ⠙ Retry happens in 0s
#> ✔ Request 3 successful!
#> [1] "cars" "chickwts"
ss %>%
sheet_rename(1, new_name = "automobiles") %>%
sheet_rename("chickwts", new_name = "poultry")
#> ✔ Renaming sheet cars to automobiles.
#> ✔ Renaming sheet chickwts to poultry.
# clean up
gs4_find("sheet-rename-demo") %>%
googledrive::drive_trash()
#> File trashed:
#> • sheet-rename-demo <id: 1IfzkaGZvWbr_4cUsE4huAfYkM33y0qZHhTaRZjG4Gp0>