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