I would like to create a bargraph with four clusters of 3 bars, with the frequency of each season for bananas, apples and pears, with each group in the same color and indicate this in a legend. The frequency of each season must total 100% .
My dataframe is like:
group season
bananas season 1
bananas season 1
bananas season 2
bananas season 3
apples season 1
apples season 2
apples season 3
pears season 1
pears season 2
pears season 3
pears season 3
pears season 1
I used count to get this dataframe:
library(tidyverse)
df<- df %>%
count(season,group)
# group season value
# bananas season 1 2
# bananas season 2 1
# bananas season 3 1
# apple season 1 1
# apple season 2 1
# apple season 3 1
# pears season 1 2
# pears season 2 1
# pears season 3 2
Thanks, I will keep in mind the format for future posts. No really, I want like the following photo, but the frequency on y-axis . The frequency of each season must total 100%, like this: Season1: banana pears+apple=100%, the same for other seasons