Overwrite worksheet using googlesheets in R

Viewed 1294

I have 2 questions.

  1. How do you overwrite a worksheet in an existing spreadsheet using the googlesheets package in R?

  2. How do you create a new worksheet in an existing spreadsheet using the googlesheets package in R?

I could not find anything in the documentation.

2 Answers

You can overwrite data in a worksheet directly using gs_edit_cells() using the trim = TRUE option to erase whatever extra was in the sheet. As the documentation points out, use of this function and, therefore, any functions that rely on it (including gs_ws_new() if input is not NULL) will be extremely slow.

The only other option available is to construct a complete file with all the worksheets of interest (e.g. .xlsx) and use gs_upload(), which will overwrite your entire file.

Related