如何修改以下代碼以顯示頻率> 10%的級別。在我的真實數據集中,分類變量有35個級別,爲了更好的可視化,我沒有把所有級別都帶入這個圖。 2-如何管理情節的大小,因爲一些級別的頻率非常高,而有些級別非常低。數據組來自汽車配套。將條件置入頻率表中。 (修改代碼)
table_ <- ggplot(States, aes(region ,fill=region))
table_ <- table_ + geom_bar()
table_ <- table_ + theme(legend.position="none")
table_ <- table_ + coord_flip()
table_ <- table_ + geom_text(aes(y = (..count..),label = ifelse((..count..)==0,"",scales::percent((..count..)/sum(..count..)))),
stat="count",colour="black",vjust=1.0,size=4)
@ mtoto,謝謝你的回覆。我得到了這個錯誤:在quantile.default(國家$ region,0.1)中的錯誤:因素是不允許的 – shoorideh