I have read in other questions with similar titles but have had no luck solving my problem.
I have a dataframe with two columns: sales and size.
sales is numeric, size is character with "Small (1-20)", "Medium (20-50)", "Large (50-100)" and "Extra Large (>200)".
I would like to make a histogram where the bins widths are equal to the different sizes. with breaks= seq(.....)
the interval is the same. Is there some way I can have different intervals in my bins using ggplot2?
I am sorry if this is a duplicate but I have really tried to find the answer in other questions and either this exact question haven't been posed or I am too stupid to understand the explanations.
mydf <- data.frame(
Sales = c(301, 5, 4, 26, 19, 82, 111, 41, 29, 12),
Size = c("Extra Large (>200)", "Small (1-20)", "Small (1-20)", "Medium (21-50)",
"Small (1-20)", "Large (51-200)", "Large (51-200)",
"Medium (21-50)", "Medium (21-50)", "Small (1-20)" ))
mydf %>% ggplot(aes(Sales))+geom_histogram(aes(y=..count..))
The histogram that is created need some band width adjustment and it's here I would like to use the "width" of the categories already described.