r - changing y scale when using fun.y ggplot -


this example of data

library(ggplot) set.seed(1) df <- data.frame(groups = factor(rep(1:10, each = 10))) x <- sample(1:100, 50) df[x, "style"] <- "lame" df[-x, "style"] <- "cool" df$style <- factor(df$style)  p <- ggplot() + stat_summary(data = df, aes(groups, style, fill = style), geom = "bar", fun.y = length, position=position_dodge()) 

(sorry, first question... don't know how present code snippets head(df) or actual plot in so. please run code understand question.)

so plot adequately presents count of every 'style' per 'groups'. however, y axis scale shows levels of factor variable 'style'. although values plotting discrete, count of every 'cool' , 'lame' per 'groups' continuous.

how change 'y' scale of barplot discrete continuous in ggplot2, in order correspond count values , not original factor levels???

you can take advantage of ggplot grouping , histogram you

p <- ggplot(df, aes(groups, fill=style)) + geom_histogram(position=position_dodge()) 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -