slices <- c(10, 12,4, 16, 8)
lbls <- c("US", "UK", "Australia", "Germany", "France")
barplot(slices, names.arg= lbls, main="Bar Plot of Countries",
col=rainbow(length(slices)))
ggplot(data, aes(x = x, fill = y)) +
geom_bar(position = "fill")
Here the full documentation :
https://www.rdocumentation.org/packages/graphics/versions/3.6.2/topics/barplot