Dplyr tutorial - An Introduction to the tbl class in dplyr

Learn how dplyr's tbl class makes it easier to work with large datasets in R. Using the Houston Flights dataset of 250,000 rows, the tutorial shows how converting a data frame to a tbl gives you a readable preview that fits your screen, displays column types, and prepares data for dplyr operations.
Chapters
If you've never missed a flight, you're spending too much time at the airport. At least that's what a Nobel Prize winning economist once said. I'd hate to miss a flight, but I'd also hate to spend too much time at an airport. The H Flights data set can help you avoid both. The data set records every flight that departed from Houston, Texas in 2011, and that's no mean feat. In 2011, Houston was a major hub for at least three carriers. Continental Airlines, ExpressJet, and Southwest Airlines, and many other airlines flew there, too. Hidden in the H Flights dataset are clues about which airlines are the most reliable. For example, you'll see which had the longest delays and which had the most cancellations. The data is saved as H Flights, a data frame that are loaded along with the H Flights package. You can look at the data directly by typing H Flights at the command line, but that might be a bittersweet experience. R will try to show you the entire data set, which is a quarter million rows long. Eventually, R will give up, but not before filling your console and its display buffer with data. Rs version of a data deluge dplyr can help you look at the data set. It provides a new structure for R, the table spelled tbl. The table is just a special type of data frame, but R knows how to display it properly. To turn HPLICE into a table, you can run table DF on it. Now, R only displays the amount of data that will fit in your console window. Not only does R cut out superfluous rows, it cuts out superfluous columns so you don't get that disorienting wraparound effect. The table display also tells you the dimensions of the full data set, as well as the names and data types of each column that is not shown. The best thing about this display is that it adapts to your window size. If you change the size of your console window and rerun H flights, R will display a different portion of the data, whichever portion fits your new window size. If your dataset is small enough, R will display the whole thing, even if it fills slightly more than one window. If you'd like to see a more complete display of the table data, you can use the function Glimpse. Glimpse shows you the data types and the initial values of each column in the data set. If you don't like the table format, you can always change your structure back with something like as DataFrame, I'll use the table format throughout this course, and I suggest that you do too. Tables do more than make your data easy to look at. They also make your data easier to work with.
More from Richie

#359 My Best Friend is AI with Valerie Tiberius, Professor of Philosophy at University of Minnesota

How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

#358 How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon







