从Google电子表格中将数据导入到R中 [英] Importing data into R from google spreadsheet

查看:129
本文介绍了从Google电子表格中将数据导入到R中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谷歌电子表格发布选项似乎有所改变。无法再以csv或tab文件的形式发布到网络上(查看最近发布的这篇文章一>)。因此,使用RCurl从Google spreadsheed将数据导入到R的常用方法不再适用:

  require(RCurl)
u< - https://docs.google.com/spreadsheet/pub?hl=zh_CN&hl=zh_CN&key=0AmFzIcfgCzGFdHQ0eEU0MWZWV200RjgtTXVMY1NoQVE&single=true&gid=4&output=csv
tc < - getURL(u,ssl.verifypeer = FALSE)
net< - read.csv(textConnection(tc))

有没有人有解决方法?

使用 googlesheets 包,这是由Jenny Bryan编写的Google Sheets R API。这是在R中分析和编辑Google表格数据的最佳方式。它不仅可以从Google表格中提取数据,还可以编辑Google表格中的数据,创建新工作表等。



该软件包可以安装 install.packages(googlesheets)



小插曲

a>入门;有关更多信息,请参阅她的GitHub存储库。如果需要,您也可以从该GitHub页面安装软件包的最新开发版本。

There seems to be a change in the google spreadsheet publishing options. It is no longer possible to publish to the web as csv or tab file (see this recent post). Thus the usual way to use RCurl to import data into R from a google spreadsheed does not work anymore:

require(RCurl)
u <- "https://docs.google.com/spreadsheet/pub?hl=en_GB&hl=en_GB&key=0AmFzIcfgCzGFdHQ0eEU0MWZWV200RjgtTXVMY1NoQVE&single=true&gid=4&output=csv"
tc <- getURL(u, ssl.verifypeer=FALSE)
net <- read.csv(textConnection(tc))

Does anyone have a work-around?

解决方案

Use the googlesheets package, a Google Sheets R API by Jenny Bryan. It is the best way to analyze and edit Google Sheets data in R. Not only can it pull data from Google Sheets, but you can edit the data in Google Sheets, create new sheets, etc.

The package can be installed with install.packages("googlesheets").

There's a vignette for getting started; see her GitHub repository for more. And you also can install the latest development version of the package from that GitHub page, if desired.

这篇关于从Google电子表格中将数据导入到R中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆