Creating a sticked bar chart (or column) with percentages and a lot of data

30 Views Asked by At

I need to create a stacked bar or column chart that has percentage on the Y axis and numbers 1-5 on the x followed by 1-6. If needed I can make two different graphs and try to merge them if repeating numbers on the x axis isn't possible. I've created the graph in excel for what I want it to look like, but am unsure how to make it in R. I need to show how many times each number, i.e. 1, has 1x, 2x, 3x, etc and do that for each number 1-5 for banana and then 1-6 for the starberry. I've included a picture of the data as well as the graph made in excel that I am trying to recreate in R.

Data I am working with:

enter image description here

Graph I am looking to recreate:

enter image description here

I tried importing the data set without the "bundle numbers" row and used

ggplot(data=Fruit_Data, aes(x=ID))+
  geom_bar(position = "fill") 

that just gave me a bar graph where they were all the same height and no differentiation between number of times a bundle appears.

I also tried

ggplot(data=Fruit_Data, aes(x=ID, y=BundleNumber))+
  geom_col()

but that made the graph horizontal and it only had bundle number for all of them in a column instead of in a row. I think I need to reorganize my data or manually name each area I want to be graphed in R, but am unsure how to do this. Any help would be greatly appreciated.

0

There are 0 best solutions below