As in the previous chapters, we will use the hflights
dataset to demonstrate how one can deal with data bearing spatial information. To this end, let's aggregate our dataset, just like we did in Chapter 12, Analyzing Time-series, but instead of generating daily data, let's view the aggregated characteristics of the airports. For the sake of performance, we will use the data.table
package again as introduced in Chapter 3, Filtering and Summarizing Data and Chapter 4, Restructuring Data:
> library(hflights) > library(data.table) > dt <- data.table(hflights)[, list( + N = .N, + Cancelled = sum(Cancelled), + Distance = Distance[1], + TimeVar = sd(ActualElapsedTime, na.rm = TRUE), + ArrDelay = mean(ArrDelay, na.rm = TRUE)) , by = Dest]
So we have loaded and then immediately transformed the hfights
dataset to a data.table
object. At the same time, we aggregated by the destination of the flights to compute:
The number of rows
The number of cancelled...