concept read_excel() in category R

This is an excerpt from Manning's book Exploring Data with R MEAP V05.
Figure 5.4 The us_cities sheet in the example Excel file is a paragon of clean data as an input for the read_excel() function. This will make your life easier.
![]()
Now that we have a sample Excel file on disk, let’s read the first sheet of that document (the ideal, clean sheet) into a tibble object. We can do this using the read_excel() function from the readxl package. This package is available in the Tidyverse and will be available on your system when installing the Tidyverse package (through install.packages(tidyverse)). However, the readxl package functions won’t be available when executing library(tidyverse). Instead, we need to explicitly use library(readxl) beforehand. So, keep in mind that library(readxl) must accompany your suite of library() statements when importing Excel files.
When using read_excel() the file name needs to be specified just as in the case of read_csv(). As before, we don’t need to add directory info since the file is available in the project directory. Because Excel workbooks can have multiple sheets, there is the sheet argument for specifying which one to use for importing. We can either specify the sheet name, or, provides its index (starting from 1). The default is to read the first sheet in the specified Excel file, and that’s just what we’ll do first. Let’s assign the resulting table to the city_table variable (Listing 5.6).
Listing 5.6. Using the read_excel() function to read the first sheet from the us_cities.xlsx file to a tibble object.
```{r read_excel, paged.print=FALSE} city_table_x <- read_excel(path = "us_cities.xlsx") #A city_table_x ```Excel files contain cell format information and, as long as there is consistency, this use of read_excel() obtains the correct column types upon reading. This is confirmed by the console printing of the tibble object.