I have a barplot situation where I would like some of the levels to be stacked and some to be dodged. Is this possible? Here is a working example.
library(ggplot2)
library(reshape)
dat <- data.frame(name=c("a","b","c","d"),
full=c(124,155,122,145),
parta=c(86,72,40,26),
partb=c(38,83,82,119))
dat1 <- reshape::melt(dat,id.vars=c("name"))
#stack
ggplot(dat1,aes(x=name,y=value,group=variable,fill=variable))+
geom_bar(stat="identity",position="stack")+
ggtitle("stack")
#dodge
ggplot(dat1,aes(x=name,y=value,group=variable,fill=variable))+
geom_bar(stat="identity",position="dodge")+
ggtitle("dodge")
In the above example, figure 1 and figure 2 (from left) are standard barplots. Figure 3 is modified to what I am looking for. I would like level 'full' to stay 'dodged' while 'parta' and 'partb' to be stacked together.
This is a dummy example. But, the practical use is when I want to show full value for something and then show how that splits into sub-components. The example above is a single split. Perhaps one might want to show multiple splits. See figure below.
Red is composed of a certain amount of blue and green. Green is further composed of a certain amount of yellow and pink. Maybe there is a better way to do this.