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(gg
Is this what you want? I adapted from the link which @Henrik pointed out.
# 1st layer
g1 <- ggplot(dat1 %>% filter(variable == "full"),
aes(x=as.numeric(name) - 0.15, weight=value, fill=variable)) +
geom_bar(position="identity", width=0.3) +
scale_x_continuous(breaks=c(1, 2, 3, 4), labels=unique(dat1$name)) +
labs(x="name")
# 2nd layer
g1 + geom_bar(data=dat1 %>% filter(grepl("part", variable)),
aes(x=as.numeric(name) + 0.15, fill=variable),
position="stack", width=0.3)