-1

I have a movie data with respect to different genres. My ultimate objective is to create a box plot of age wise ratings of films for different genres i.e. if action is one of the genres, I want to create a box plot of age wise ratings with each box plot representing a certain age group. I tried using the code :

boxplot(cbind(Action_Subset$U_18_ratings,Action_Subset$Between_18_to_29_ratings,Action_Subset$Between_30_to_44_ratings,Action_Subset$Ratings_above_45))

I am able to create the box plots but unable to represent it according to different age groups.

enter image description here

How can I highlight which boxplot represents ratings for particular age group.

zx8754
  • 52,746
  • 12
  • 114
  • 209

1 Answers1

0

Expecting that each column has same number of rows!

    data_boxplot <- cbind(Action_Subset$U_18_ratings,
                          Action_Subset$Between_18_to_29_ratings,
                          Action_Subset$Between_30_to_44_ratings,
                          Action_Subset$Ratings_above_45) %>% 
mutate(ID = row_number()) %>% 
pivot_longer(-ID)

p <- ggplot(dat_plot)+   geom_boxplot(aes(x = name, y = value, fill = name)) 
p
sveer
  • 427
  • 3
  • 16