To create a stacked bar plot with the geom_bar()
of the "carrier" variable in nycflights
, we can use the fill
argument in addition to the aes()
function.
Here is the code to create the plot:
main.r110 chars6 lines
This will create a stacked bar plot of the "carrier" variable in the flights
dataset, where the bars will be stacked according to the number of flights per year by each carrier. The fill
argument determines what variable will be used to define the different colors of the bars in the plot.
gistlibby LogSnag