Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read data from google drive using R in colab?

I have to read data in csv format from google drive using R in colab. I know how to do it using python, however I am not getting relevant ways to do it in R.

like image 805
Vishal Avatar asked Jan 15 '20 06:01

Vishal


People also ask

How do I read Google Drive in Colab?

Accessing Google Drive from Google ColabOnce the Drive is mounted, you'll get the message “Mounted at /content/gdrive” , and you'll be able to browse through the contents of your Drive from the file-explorer pane. Now you can interact with your Google Drive as if it was a folder in your Colab environment.

How do you load dataset from Google Drive in Colab?

From Github It is the easiest way to upload a CSV file in Colab. For this go to the dataset in your GitHub repository, and then click on “View Raw”. Copy the link to the raw dataset and pass it as a parameter to the read_csv() in pandas to get the dataframe.

How do I import a dataset in Google colab in R?

Upload a file directly through the shortcut in the side menu thingy. Just click the icon there and upload your file to drive. Then, you can run normal r import functions by following the internal path like korakot put in this answer.


1 Answers

If you can make your data public, you can use gdown.

system("gdown --id 12uRyLU-aAdInBtkVubhI4l3PmbYIo5aE")
data = read.csv("country_culture.csv")

Here's an example notebook.

like image 165
korakot Avatar answered Oct 05 '22 22:10

korakot