-2

I'm trying to create a grouped barplot using ggplot due to the more aesthetically pleasing quality it produces. I have a dataframe, together, containing the values and the name of each value but I can't manage to create the plot it? the dataframe is as follows

          USperReasons      USperReasonsNY                 USuniquNegR
1    0.198343304187759   0.191304347826087                 Late Flight
2     0.35987114588127   0.321739130434783      Customer Service Issue
3   0.0667280257708237    0.11304347826087                Lost Luggage
4   0.0547630004601933 0.00869565217391304     Flight Booking Problems
5    0.109065807639208   0.121739130434783                  Can't Tell
6  0.00460193281178095                   0             Damaged Luggage
7   0.0846755637367694  0.0782608695652174            Cancelled Flight
8   0.0455591348366314  0.0521739130434783                  Bad Flight
9   0.0225494707777266  0.0347826086956522                   longlines
10  0.0538426138978371  0.0782608695652174 Flight Attendant Complaints

I tried different methods with errors in all, one such example is below

ggplot(together,aes(USuniquNegR, USperReasons,USperReasonsNY))+ geom_bar(position = "dodge") 

Thanks, Alan.

1 Answers1

1
df <- reshape2::melt(together, 3)

ggplot(reshape2::melt(df, 3), 
    aes(USuniquNegR, value, fill = variable)) + 
        geom_bar(stat = 'identity', position = 'dodge') + 
        coord_flip() + 
        theme(legend.position = 'top')

Output Plot

TheRimalaya
  • 4,232
  • 2
  • 31
  • 37