5

I have been trying to solve this problem, but with no success. Imagine I have a google worksheet called "database". In this worksheet I have a sheet called "Sheet1". And in this sheet I have a table (that starts from A1) with column names "a1", "a2", "a3".

Now, I want to append a new row with values "12", "23", "34". For this I input this code:

library(googlesheets)

worksheet <- gs_title("database")
gs_add_row(ss=worksheet, ws="Sheet1", input = c("12","23","34"))

But when I do this, I get the following error:

Input is too long. Only first 0 elements will be used.
Error: all(lengths == 1L | lengths == n) is not TRUE

Thanks a lot

Rodrigo Guinea
  • 328
  • 4
  • 16

1 Answers1

6

gs_add_rows only can add rows once the header is available in the google sheet so you need to create the first row or the header information with gs_edit_cells() before you use add_rows.

This is explained in the googlesheets vignette.

Here is a screenshot of the appropriate code from the Vignette

hank_044
  • 176
  • 6
  • 4
    It seems more than just the header is necessary, I had to add the header **AND** one row before this error disappeared. – s_baldur May 05 '18 at 17:07