我正在尝试将我的 Google Drive 中的电子表格读取到 R 中,而无需在本地下载它。根据这个论坛上其他问题的建议,我一直在使用googledrive
andgooglesheets4
包。我运行了以下代码:
> drive_find(type = "spreadsheet",n_max = 1)
# A tibble: 1 x 3
name id drive_resource
* <chr> <chr> <list>
1 school_data 1TaO0U5teh-mnriPLzHmlAjrkEMEPivpzdcaqEPh5ohc <list [34]>
> (DRIVE = drive_get(id="1TaO0U5teh-mnriPLzHmlAjrkEMEPivpzdcaqEPh5ohc"))
# A tibble: 1 x 3
name id drive_resource
* <chr> <chr> <list>
1 school_data 1TaO0U5teh-mnriPLzHmlAjrkEMEPivpzdcaqEPh5ohc <list [34]>
> sheets_get(DRIVE)
Spreadsheet name: school_data
ID: 1TaO0U5teh-mnriPLzHmlAjrkEMEPivpzdcaqEPh5ohc
Locale: en_US
Time zone: America/Los_Angeles
# of sheets: 1
(Sheet name): (Nominal extent in rows x columns)
school_data: 667 x 35
> read_sheet(DRIVE)
Reading from 'school_data'
Error in parse(df$cell, ctype, ...) : is_string(ctype) is not TRUE
> sheets_read(DRIVE)
Reading from 'school_data'
Error in parse(df$cell, ctype, ...) : is_string(ctype) is not TRUE
我得到了read_sheet()
和sheets_read()
函数的错误。我不知道从这里去哪里。有任何想法吗?
编辑:
按照评论中的建议,我运行了以下代码:
> devtools::install_github("r-lib/gargle")
Downloading GitHub repo r-lib/gargle@master
These packages have more recent versions available.
Which would you like to update?
1: curl (3.2 -> 4.2 ) [CRAN] 2: glue (1.3.0 -> 1.3.1) [CRAN] 3: jsonlite (1.5 -> 1.6 ) [CRAN] 4: mime (0.6 -> 0.7 ) [CRAN]
5: openssl (1.0.2 -> 1.4.1) [CRAN] 6: R6 (2.2.2 -> 2.4.1) [CRAN] 7: Rcpp (1.0.0 -> 1.0.3) [CRAN] 8: sys (3.2 -> 3.3 ) [CRAN]
9: CRAN packages only 10: All 11: None
Enter one or more numbers separated by spaces, or an empty line to cancel
1: 10
curl (3.2 -> 4.2 ) [CRAN]
glue (1.3.0 -> 1.3.1) [CRAN]
jsonlite (1.5 -> 1.6 ) [CRAN]
mime (0.6 -> 0.7 ) [CRAN]
openssl (1.0.2 -> 1.4.1) [CRAN]
R6 (2.2.2 -> 2.4.1) [CRAN]
Rcpp (1.0.0 -> 1.0.3) [CRAN]
sys (3.2 -> 3.3 ) [CRAN]
Installing 8 packages: curl, glue, jsonlite, mime, openssl, R6, Rcpp, sys
Installing packages into ‘C:/Users/krosi/OneDrive/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
Error: (converted from warning) package ‘curl’ is in use and will not be installed
并遇到了同样的问题。
我还提供了指向数据集的链接以实现可复制性。 https://docs.google.com/spreadsheets/d/1TaO0U5teh-mnriPLzHmlAjrkEMEPivpzdcaqEPh5ohc/edit?usp=sharing