I would like to read in R a dataset from google drive as the screenshot indicated.
Neither
url <- "https://drive.google.com/file/d/1AiZda_1-2nwrxI8fLD0Y6e5rTg7aocv0"
temp <- tempfile()
download.file(url, temp)
bank <- read.table(unz(temp, "bank-additional.csv"))
unlink(temp)
nor
library(RCurl)
bank_url <- dowload.file(url, "bank-additional.csv", method = 'curl')
works.
I have been working on this for many hours. Any hints or solutions would be really appreciate.
The google drive share link is not the direct file link, so
1. download.file
2. RCurl
first method in accepted answer
only download the web page showing the file, not file itself. You can edit the downloaded file and see it's a html file.You can find out the actual direct link to file with this. With the direct link all the regular download methods will work.
For very detailed discussions about getting the direct link or downloading it, see this question.
Google drive api require client to sign in, so googledrive package also ask you to sign in google if not already signed in.
Try
The URL should correspond to the URL that you use to download the file using your browser.
As @Mako212 points out, you can also make use of the
googledrive
package, substitutingdrive_download
fordownload.file
: