[英]How can I handle the error “Error: all(lengths == 1L | lengths == n) is not TRUE”?
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".
在这个工作表中,我有一个名为“Sheet1”的工作表。 And in this sheet I have a table (that starts from A1) with column names "a1", "a2", "a3".
在这张表中,我有一个表(从A1开始),列名为“a1”,“a2”,“a3”。
Now, I want to append a new row with values "12", "23", "34". 现在,我想追加一个值为“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 非常感谢
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. gs_add_rows只能在Google表格中有标题后添加行,因此您需要在使用add_rows之前使用gs_edit_cells()创建第一行或标题信息。
This is explained in the googlesheets vignette. googlesheets vignette中对此进行了解释。
Here is a screenshot of the appropriate code from the Vignette 以下是Vignette中相应代码的屏幕截图
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.