Let’s say I am modelling data on flights and delays. I have 14 airlines (
carrier variable) in the data below. I would like to know if I can create fewer categories or clusters of this categorical data, so instead of having 14 airlines maybe end up with 3 or 4 clusters of airlines.
require(data.table) # Data takes ~30 seconds to load flights <- as.data.table(read.csv(url("https://raw.githubusercontent.com/wiki/arunsrinivasan/flights/NYCflights14/flights14.csv"))) length(unique(flights$carrier)) km <- kmeans(flights[,.(dep_delay,carrier)], centers = 4, nstart = 1)
Is there any methodology that could be used? I tried k-means but it seems it is not the most appropriate.