2017-08-09 50 views
-2

變成一個條形圖我怎麼會做出這樣的R A水平條形圖,其中X軸具有計數和y軸有標籤,我知道這看起來很容易,但ggplot犯規讓你輸入表格數據我怎麼使用ggplot

>table(df$Primary.Issue.Category) 
    Billing, coverage, coordination of benefits   Concern over standard receipt time    Difficulty finding new supplier Difficulty receiving products in general 
               6           1           4           89 
     Difficulty receiving specific products      Low quantity/quality Problems repairing due to service issues     Supplier compliance issues 
               3           10           9           8 
       Supplier fraud, waste, or abuse      Supplier service issues 
               2           4 
+0

的可能的複製[水平Barplot在GGPLOT2](https://stackoverflow.com/questions/10941225/horizo​​ntal-barplot-in-ggplot2) – useR

回答

1

嘗試coord_flip()

df<-as.data.frame(table(df$Primary.Issue.Category)) 
names(df)<- c("labels", "counts") 
ggplot(df, aes(x=labels, y=counts)) + 
geom_bar(stat='identity') + 
coord_flip()