Session Ready
Exercise

Import an Excel sheet

Now that you know the names of the sheets in the Excel file you want to import, it is time to import those sheets into R. You can do this with the read_excel() function. Have a look at this recipe:

data <- read_excel("data.xlsx", sheet = "my_sheet")

This call simply imports the sheet with the name "my_sheet" from the "data.xlsx" file. You can also pass a number to the sheet argument; this will cause read_excel() to import the sheet with the given sheet number. sheet = 1 will import the first sheet, sheet = 2 will import the second sheet, and so on.

In this exercise, you'll continue working with the latitude.xlsx file.

Instructions
100 XP
  • Import the first Excel sheet of "latitude.xlsx". Call the resulting data frame latitude_1. You can import the first sheet using the sheet argument. This sheet contains the names as the first row, so there's no need to specify the col_names argument.
  • Import the sheet named "1900" as well, and assign it to latitude_2. Again you should use sheet to define the sheet; this time you can use the sheet name.
  • Store both the data frames latitude_1 and latitude_2 in a list, that you call lat_list.
  • Display the structure of lat_list.