0

Data that I'm working with:

Genre        SBudget   SRevenue
   <chr>          <dbl>      <dbl>
 1 Action    1958100000 5904640000
 2 Comedy    1321500000 4150600000
 3 Drama      749200000 2301300000
 4 Adventure  342000000 1664800000
 5 Fantasy    350000000 1478200000
 6 Horror     193500000  667800000
 7 Sci-Fi     142000000  530000000
 8 Musical    136000000  501200000
 9 Family      90000000  349900000
10 Crime      135000000  192400000
11 Thriller    31000000  172500000
12 Romance     45500000  156400000
13 Biography   20000000    8300000

I want to display a bar plot where Budget and Revenue are displayed side by side like in "dodge" position in geom_bar, for each genre and with the money on the y-axis.

I tried fiddling with the ggplot and geom_bar function but to no avail

ggplot(data=genrereport, aes(x=Genre, y=SRevenue, fill=SBudget)) +
  geom_bar(stat="identity", position="dodge")

the plot i got This code is obviously wrong

stefan
  • 90,330
  • 6
  • 25
  • 51
PrakharS
  • 1
  • 2
  • 2
    `tidyr::pivot_longer(genrereport, -Genre) |> ggplot(aes(Genre, value, fill=name)) + geom_col(position="dodge")`. ggplot2 works better with "longer" data where each aesthetic distinction (e.g. budget vs. revenue) is distinguished within a column. – Jon Spring May 30 '23 at 18:29

0 Answers0