from_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().
from_sheet: Sheet to copy, 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.
to_ss: The Sheet to copy to. Accepts all the same types of input as from_ss, which is also what this defaults to, if unspecified.
to_sheet: Optional. Name of the new sheet, as a string. If you don't specify this, Google generates a name, along the lines of "Copy of blah". Note that sheet names must be unique within a Sheet, so if the automatic name would violate this, Google also de-duplicates it for you, meaning you could conceivably end up with "Copy of blah 2". If you have better ideas about sheet names, specify to_sheet.
.before, .after: Optional specification of where to put the new sheet. Specify, at most, one of .before and .after. Refer to an existing sheet by name (via a string) or by position (via a number). If unspecified, Sheets puts the new sheet at the end.
Returns
The receiving Sheet, to_ ss, as an instance of sheets_id.
Examples
ss_aaa <- gs4_create("sheet-copy-demo-aaa", sheets = list(mtcars = head(mtcars), chickwts = head(chickwts)))# copy 'mtcars' sheet within existing Sheet, accept autogenerated namess_aaa %>% sheet_copy()# copy 'mtcars' sheet within existing Sheet# specify new sheet's name and locationss_aaa %>% sheet_copy(to_sheet ="mtcars-the-sequel", .after =1)# make a second Sheetss_bbb <- gs4_create("sheet-copy-demo-bbb")# copy 'chickwts' sheet from first Sheet to second# accept auto-generated name and default locationss_aaa %>% sheet_copy("chickwts", to_ss = ss_bbb)# copy 'chickwts' sheet from first Sheet to second,# WITH a specific name and into a specific locationss_aaa %>% sheet_copy("chickwts", to_ss = ss_bbb, to_sheet ="chicks-two", .before =1)# clean upgs4_find("sheet-copy-demo")%>% googledrive::drive_trash()
See Also
If the copy happens within one Sheet, makes a DuplicateSheetRequest: