Session Ready
Exercise

The col_names argument

Apart from path and sheet, there are several other arguments you can specify in read_excel(). One of these arguments is called col_names.

By default it is TRUE, denoting that the first row in the Excel sheets denote the column names. If this is not the case, you can set col_names to FALSE. In this case, R will choose column names for you. You can also choose to set col_names to a character vector with names for each column. It works exactly the same as in the readr package.

You'll be working with the [latitude_nonames.xlsx]() file. It contains the same data as latitude.xlsx but has no column names in the first row of the excel sheets.

Instructions
100 XP
  • Import the first Excel sheet of "latitude_nonames.xlsx" and store the result in latitude_3. Have R set the column names of the resulting data frame itself.
  • Import the first Excel sheet of latitude_nonames.xlsx; this time, specify the column names to be "country" and "latitude". Store the resulting data frame in latitude_4.
  • Print out the summary of latitude_3.
  • Print out the summary of latitude_4. Can you spot the difference with the other summary?