0

I am trying to create a bar graph plotting the quality of wine with the wine samples. However, the graph gives me a y-axis with e values (for example 2e + 05). I want the y axis to show how many of the wines are of which qualities.

winer <- read.csv('winequality-red.csv')
wine_red <- winer %>% separate(fixed.acidity.volatile.acidity.citric.acid.residual.sugar.chlorides.free.sulfur.dioxide.total.sulfur.dioxide.density.pH.sulphates.alcohol.quality, into = c("fixed.acidity","volatile.acidity","citric.acid","residual.sugar","chlorides","free.sulfur.dioxide","total.sulfur.dioxide","density","pH","sulphates","alcohol","quality"), sep = ";", convert = TRUE) 
wine_red <- wine_red %>% mutate(ID = as.numeric(row_number()))
wine_red %>% ggplot(aes(x = quality, y = ID,color = factor(quality), fill = factor(quality))) + geom_bar(stat = 'identity', size = 2, show.legend = FALSE) + scale_colour_brewer(palette = "YlOrRd", direction =  1) + scale_fill_brewer(palette = "BuPu") + xlab("Quality of Wine") + ylab("Number of wines") + ggtitle("Wine qualities")

The graph gives me a y-axis with e values (for example 2e + 05). I want the y axis to show how many of the wines are of which qualities. I think it is because of me trying to plot quality against the ID column I made, but I couldn't get the plot to work and format it further.

This code gives me the correct y axis, but wouldn't let me format it further.

ggplot(wine_red) + 
  geom_histogram(mapping = aes(x = quality))

stefan
  • 90,330
  • 6
  • 25
  • 51
Elina
  • 37
  • 2

0 Answers0