Hope, it's: Downloading google drive files in rstudio
Downloading google drive files in rstudio | |
Downloading google drive files in rstudio | |
Downloading google drive files in rstudio |
Downloading google drive files in rstudio - fantasy
Reading in Google Spreadsheets to R
It's helpful to be able to collaborate in collecting data. Google spreadsheets is a useful tool for this.
For those implementations of R that support the web protocol used by Google, there is a simple way to read Google spreadsheets into R via the function in the mosaic package. Otherwise, there is a multi-step process that is not too difficult.
How Will I Know What to Do?
Check whether the package is installed on your system. If it is, then you're good to go with the method. The
If you are running R on your own desktop rather than using a server, try installing . On many systems, it is very easy; on others it is not possible unless you have some detailed knowledge of how to install command-line software.
Using
(See below for how to read Google spreadsheets without.)
You will have to set up your spreadsheet on Google to talk with R. This is a one-time operation that will continue to work even if you add more data to the spreadsheet.
- In Google spreadsheets, choose File/Publish to the web
- Start publishing, checking “Automatically republish when changes are made”
- Under “Get a link to the published data”
- Select “CSV” Sheet 1 All cells
- Copy the link. You'll need it in a bit.
Now, to R …
1. Make sure you have the mosaic package running:
1. Paste the link from step (5) into R as a quoted argument to command, like this
You can email this command to your collaborators. You may find it convenient to use the history command (searching on “fetchGoogle”) to find the command again when you need it.
Without
Unfortunately, the particular web protocol used by Google spreadsheets is not yet available in all implementations of R. Until it is, here are the several steps to read a Google spreadsheet into R. (If you're running a desktop version of R, check out the section “If you can install RCurl…”)
- In Google spreadsheets, choose File/Download As/Comma Separated Values (CSV). This will save a file to your computer. Make note of its name.
- If you are running R on your own computer, e.g. through the desktop version of RStudio, use to read in the spreadsheet you have just saved. When given an empty argument, will bring up a file browser which you can use to navigate to the file you just saved. BUT …
- If you are running R remotely, on an RStudio server through a web browser, you will need to upload the CSV file to the RStudio server. Here's how
- Go to the Files tab in RStudio and press the “Upload” button. (Look for the “Files” tab, not the “File” menu item at the top of the screen.)
- In the dialog window that appears, navigate to the CSV file you have just downloaded from Google spreadsheets. Upload this to the RStudio server.
- Going back to the RStudio console, use with an empty argument and navigate to the file you have just uploaded to the RStudio server.
This is a pain, I know.
-
-