2017-10-16 66 views
-1

所以我有一個非常複雜的(至少對我來說這是哈哈)ggplot,我試圖從這些數據創建。ggplot從這張表中堆積的條形圖

Issue = c("Difficulty receiving products in general", 
"Supplier compliance issues", "Supplier fraud, waste, or abuse", 
"Difficulty receiving products in general", "Difficulty receiving products in general", 
"Supplier fraud, waste, or abuse", "Supplier service issues", 
"Problems repairing due to service issues ", "Problems repairing due to service issues ", 
"Other", "Billing, coverage, coordination of benefits", "Problems repairing due to service issues ", 
"Difficulty receiving products in general", "Difficulty receiving products in general", 
"Low quantity/quality", "Difficulty receiving products in general", 
"Difficulty receiving products in general", "Supplier service issues", 
"Problems repairing due to service issues ", "Problems repairing due to service issues ", 
"Problems repairing due to service issues ", "Problems repairing due to lack of inventory ", 
"Supplier service issues", "Difficulty receiving products in general", 
"Supplier service issues") 

Resolution = c("Current supplier resolved the issue", 
"Current supplier resolved the issue", "Current supplier resolved the issue", 
"Supplier educated about inquiry\n", "Beneficiary educated about inquiry ", 
"Supplier educated about inquiry\n", "Beneficiary educated about DMEPOS\n", 
"Beneficiary educated about inquiry ", "Beneficiary educated about inquiry ", 
"Beneficiary educated about inquiry ", "Beneficiary educated about suppliers", 
"The case unresolved ", "The case unresolved ", "Beneficiary educated about DMEPOS\n", 
"Current supplier resolved the issue", "Current supplier resolved the issue", 
"Beneficiary educated about DMEPOS\n", "Beneficiary educated about suppliers", 
"New supplier found ", "Beneficiary educated about suppliers", 
"Supplier educated about inquiry\n", "New supplier found ", 
"New supplier found ", "Beneficiary educated about DMEPOS\n", 
"The case unresolved ") 

df <- data.frame(Issue,Resolution) 
crosstable<- table(df$Issue,df$Resolution) 

我想創建一個具有在X軸上問題堆積條形圖ggplot,然後在y軸數,也顯示了每個問題是如何通過決議進行細分。這在Excel中很容易做到,但是由於我在R中製作其他圖表,我希望保持美觀一致。

+0

你到目前爲止嘗試過什麼? – Mako212

+1

你有沒有嘗試過任何'ggplot()'代碼?看起來像一個編碼服務請求,而不是一個特定的問題 – Nate

回答

1

嘗試:

ggplot(df, aes(Issue, fill = Resolution)) + geom_bar() 

如果不是訂單,只需切換問題和解決的位置。