5213/showing-percentage-instead-of-counts-in-a-bar-plot-ggplot2-r
I am working with the 'mtcars' dataset and have made this bar plot for the 'cyl' column:
For the y-axis, i want to see percentage instead of count. Is that possible?
Load the 'scales' package first, which gives different attributes to alter your scales.
library(scales)
Now, the below command is what you need:
ggplot(data = mtcars,aes(x=factor(cyl)))+geom_bar()+scale_y_continuous(labels=percent)
@prardhana, Use scale_fill/color/size_discrete/contin....(labels = c()). compare both to see ...READ MORE
R provides 3 basic indexing operators. Refer ...READ MORE
You can use mtabulate in the following way: library(qdapTools) cbind(data[1], ...READ MORE
You can use the plyr function: data <- ...READ MORE
By Using gridExtra library we can easily ...READ MORE
You can use the theme layer to ...READ MORE
The below command will give you the ...READ MORE
Use facet_grid() and pass the field to ...READ MORE
You can use the scale_x_discrete() function with ...READ MORE
You just have to add 'outlier.shape=NA' inside ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.