Compute market shares in an airport or city
market_shares.RdCompute market shares by airport or by city, with flexibility to specify how the carrier is defined.
Value
a dataframe with the carrier and orig columns, and a market_share column that contains the market share of that carrier in that location, as a proportion.
Details
This will calculate market shares and return them as proportions by airport or city and by operator.
Examples
data = tibble::tribble(
~origin, ~airline, ~Passengers,
"CLT", "American", 10,
"CLT", "United", 5,
"RDU", "American", 5,
"RDU", "United", 7
)
market_shares(data, airline, carrier)
#> Error in group_by(dataframe, { { carrier }}, { { orig }}): Must group by variables found in `.data`.
#> ✖ Column `carrier` is not found.