0
我有一个数据框有10个值在每种5种和有2种类型。ggplot文本在每个角落与facet
df <- data.frame(x2=rnorm(100),y2=rnorm(100), type = c(rep("type a", 50), rep("type b", 50)), kind = rep(LETTERS[1:5],10))
我想打印每个象限中百分比值的标签。我当前的代码是:
ggplot(df, aes(x2, y2)) + geom_point() +
geom_vline(xintercept = 0) +
geom_hline(yintercept = 0) +
geom_text(data = df, aes(x2, y2, label = "")) +
facet_grid(type~kind)
预期输出(例如我展示实物的比例和类型的B,我要绘制的百分比值对所有种类和类型):
任何建议都会很棒。谢谢!
这样一个很好的解决方案。非常感谢@baptiste –
我确定有更好的表格制作方式,但我对xtabs和co,或dplyr不熟悉。 – baptiste