R: Upload Google Sheets Dataset to RStudio

I. Introduction

Google Sheets is a powerful and easy way to collect data. Once you have your data stored as a Google Sheet, having the ability to import this data into RStudio for analysis is highly beneficial. Getting your data into RStudio is actually fairly easy. The following are the steps required to import your data into RStudio. Good Luck!

1. Once your data is all set in your Google Sheet, you need to make sure your data is properly formatted. Spend a little bit of time to make sure this is done correctly so that there are no issues when you upload your data to RStudio. First, make sure that you don't have any commas or % or $ signs in your data. Also, make sure your column names are properly formatted with NO spaces or symbols. For example, if your column name is "student height", change this column name to simply: "height" or "student_height". Finally, check to see if there is any missing data in your spreadsheet. Missing data will make your analysis more complicated once it is imported into RStudio.

2. Once your data has been properly formatted, in your Google Sheet, (in the top right) click "File", then "Download as", then choose "Comma-separated values (.csv)". Then name and save your .csv file to your computer.

3. Once you save the file to your computer, go to RStudio. Once in RStudio, click "Files" (Files can be found not on the top right, but in the window where you get plots and R help documentation), then "Upload" and then upload the .csv file that you just created.

4. Once the data has been uploaded to RStudio, in the source window type, highlight, and then run:

# To import your data into your current RStudio session, run the following line
# and be extra sure that your file name is exactly the same.
my.data = read.csv("whatever.your.filename.goes.here.csv")  

# To view your data

5. If you can see your data, congratulations, you can now begin to explore, analyze, and graph your data!

Note: If you can not see your data or you ran into an error, check 1) that your file name is correct and/or 2) that your data is properly formatted as outlined in part #1.