[英]Check if a worksheet exists
如何使用googlesheets包检查电子表格中是否存在带有标题的特定工作表?
If you know what the title of the worksheet is, you can check for it this way. 如果您知道工作表的标题是什么,则可以通过这种方式进行检查。 Here is a toy example.
这是一个玩具示例。 Load the gapminder test data first:
首先加载gapminder测试数据:
> library(googlesheets)
> gs_gap() %>% gs_copy(to = "Gapminder")
This will send you to Google to authenticate. 这会将您发送到Google进行身份验证。 Once you do that, close the browser, and return to R. The worksheets available are stored in
$ws$ws_title
: 完成后,关闭浏览器,然后返回R。可用的工作表存储在
$ws$ws_title
:
> gap <- gs_title("Gapminder")
> gap$ws$ws_title
[1] "Africa" "Americas" "Asia" "Europe" "Oceania"
So you can check and see if a particular named worksheet is available like this: 因此,您可以检查并查看是否有特定的命名工作表可用,如下所示:
> ("Africa" %in% gap$ws$ws_title)
[1] TRUE
There is more info in the googlesheets
vignette here which should help you make the connection to your spreadsheet: https://cran.r-project.org/web/packages/googlesheets/vignettes/basic-usage.html 此处的
googlesheets
小插图中有更多信息,可帮助您建立与电子表格的连接: https : googlesheets
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.