How do I color a two toned bar plot based on a two variables that add up to the total length of the bar?

  Kiến thức lập trình

I apologize for the confusing title – I wasn’t quite sure how to phrase what I wanted.

The dataset that I am working on is a subdataset I created from my main data. It looks something like this:

Genre meanGrossing meanBudget MaleGrossing
Family 1097910750 188821479 292776200
Action 1374979940 184161982 511320665

There are 16 other rows but this is just a small section of my dataset. Malegrossing is calculated for each genre. I am going to add another variable that calculates Femalegrossing – I know how to do this.

So far, the current dataset I am working with was obtained from the following code being repeated and ‘cbind’ for each genre. There where issues with the raw data I was using and this was the only way we could work with it instead of against it.

genre = "Animation", raw_data %>% filter(Animation == 1) %>% summarise(meangross = mean(InflatedGross),meanBudget = mean(InflatedBudget), Malegross = ((mean(Proportion_male))*meangross)))

The adding of the variables Malegrossing and Femalegrossing will always equal to meanGrossing.

I want to present the information in something like this:

Y axis is meangross. X axis is each genre category. Each bar graph is composed of two colors, blue and pink totaling up to the meangross showing how much they each make up the entire grossing.

Please let me know if more clarification is needed.

Recognized by R Language Collective

New contributor

Rose Campos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

2

LEAVE A COMMENT