Loading Excel Data in RStudio
The Goal
We have been using data that can be easily loaded into R using one line of code. However, what if we want to be able to analyze our own data sets using R? Typically, such data is in the form of a excel file. Today, we are going to talk about how to load data from such a file into R.
Getting the Data
The first thing we need to do is get the data. Go to Canvas and click on the data link. A Google Sheet will open up. You need to download the data as an excel file.
Go to File, then Download, and then choose Excel.
Moving the data into RStudio
- Step 1 Open RStudio.
- Step 2 Look at the upper right hand panel of your screen, which should be the Environment Tab.
- Step 3 Find “Import Dataset” or “Import” and click on it.
- Step 4 Choose “From Excel”
- Step 5 Click Browse and find your data (DataForFigure2.1WHR2023.xls). For most of us, it is probably in Downloads.
- Step 6 In the Code Preview, highlight the first two lines of code and copy them.
- Step 7 Click Import.
- Step 8 Open a RMarkdown document and create a code chunk. In that chunk, paste the two lines of code you copied from the code preview.
And you are done!!