r - ggplot2: Add a stacked bar showing the total distribution -


the following snippet creates stacked bars showing distribution of "clarity" "cut".

data(diamonds) qplot(cut, data=diamonds, geom="bar", fill=clarity, position="fill") 

another plot shows total distribution of "clarity" entire dataset.

qplot(x=factor(""), data=diamonds, geom="bar", fill=clarity, position="fill") 

is there way add second plot bar first plot, label "total"?

bycut total

many approaches here's one:

diamonds2 <- diamonds diamonds2$cut <- "total" diamonds3 <- rbind(diamonds, diamonds2)  qplot(cut, data=diamonds3, geom="bar", fill=clarity, position="fill") 

enter image description here


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -