使用R从Google驱动器下载文件

编程入门 行业动态 更新时间:2024-10-23 07:20:55
本文介绍了使用R从Google驱动器下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经尝试过建议以读取Google驱动器中的csv文件.我点击该文件以获取可共享的文件链接.

I have tried the recommendations to read a csv file in google drive. I write click on the file to get the sharable file link.

我尝试了这4种方法中的每一种:(当我右键单击文件名时,我用ZZZZ代替了链接).

I have tried each of these 4 methods: (I have substituted ZZZZ for what I get as the link when I right-click on the file name).

x <- curl("drive.google/open?id=ZZZZ") data <- read.csv(x,skip=5,stringsAsFactors = F)

id <- "ZZZZ" data <- read.csv(sprintf("drive.google/open?id=%s&export=download",id),skip=5,stringsAsFactors = F)

data <- read.csv("drive.google/open?id=ZZZZ",skip=5,stringsAsFactors = F)

sURL <- sprintf("drive.google/open?id=%s&export=download",id) con <- curl(sURL); con2 <- read.csv(con,skip=5,stringsAsFactors = F)

推荐答案

有一个很棒的软件包"gsheet"(上帝保佑作者). 1.在Google云端硬盘中以Google表格的形式打开您的文件. 2.然后将您的文件公开(单击链接的任何人都可以使用). 3.然后在R中使用此代码:

There is a great package 'gsheet' (God bless the author). 1. Open your file in google drive as google sheet. 2. Then make your file public (available to anyone who clicks the link). 3. Then use this code in R:

install.packages('gsheet') library(gsheet) data <- gsheet2tbl('drive.google/open?id= COPY HERE YOUR ID LINK')

更多推荐

使用R从Google驱动器下载文件

本文发布于:2023-11-28 13:16:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642563.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:驱动器   文件   Google

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!