R ggplot bar graph with color filled, how to normalized each column to percentage? [duplicate]


I have a bar graph with color filled plotting like this,

ggplot(mtcars) + aes(x=factor(cyl), fill=factor(vs))+geom_bar()

enter image description here

How to transform each column to percentage? something like the following?

Any hint is appreciated. Thank you!

enter image description here


Answers: