I'm trying to make a figure using ggplot and facets; facets based on a categorical variable, and in each plot horizontal barplots of proportions. Hope this makes sense :)
dummy dataset:
testdf <- read.csv(text = "ONE,TWO
0.01,cat1
0.01,cat1
0.06,cat1
0.06,cat1
0.011,cat1
0.011,cat1
0.011,cat1
0.016,cat1
0.016,cat1
0.01,cat2
0.06,cat2
0.06,cat2
0.06,cat2
0.011,cat2
0.011,cat2
0.011,cat2
0.012,cat2
0.012,cat2")
Its not working for me, this is what I came up with so far:
ggplot(testdf, aes(x=TWO, y=ONE)) +
geom_jitter(position=position_jitter(width=0.3, height=0.2), aes(factor(TWO)), alpha=0.9)+
geom_bar(stat='identity',alpha = 0.5, show.legend = FALSE, aes(fill=factor(TWO))) + facet_grid(.~TWO)+
coord_flip()
答案 0 :(得分:0)