How to download a shared file from Google Drive in R

How To
A tutorial on how to download a shared file with ‘anyone with the link’ access rights from Google Drive in R.

Rohit Farmer


October 14, 2022


To download a shared file with “anyone with the link” access rights from Google Drive in R, we can utilize the googledrive library from the tidyverse package. The method described here will utilize the file ID copied from the shared link. Typically googledrive package is used to work with a Google Drive of an authenticated user. However, since we are downloading a publicly shared file in this tutorial, we will work without user authentication. So, please follow the steps below.

Step 1: Copy the file ID from the share link.

Below is a share link from my Google Drive pointing to an R data frame.

This string 1vj607etanUVYzVFj_HXkznHTd0Ltv_Y4 is the file ID that we will use to download.

Step 2: Download the file using an authenticated connection.

if(!require(googledrive)) install.packages("googledrive")

public_file <-  drive_get(as_id("1vj607etanUVYzVFj_HXkznHTd0Ltv_Y4"))
drive_download(public_file, overwrite = TRUE)
File downloaded:
• hdstim-example-data.rds <id: 1vj607etanUVYzVFj_HXkznHTd0Ltv_Y4>
Saved locally as:
• hdstim-example-data.rds

The downloaded data frame.



BibTeX citation:
  author = {Rohit Farmer},
  title = {How to Download a Shared File from {Google} {Drive} in {R}},
  date = {2022-10-14},
  url = {},
  langid = {en}
For attribution, please cite this work as:
Rohit Farmer. 2022. “How to Download a Shared File from Google Drive in R.” October 14, 2022.